Network performance

Michael Sparks michaels at rd.bbc.co.uk
Tue Aug 23 04:14:08 EDT 2005


Roland Hedberg wrote:
> What the protocol has to accomplish is extremely simple; the client
> sends a number of lines (actually a RDF) and the server accepts or
> rejects the packet. That's all !
...
> Now, presently I'm using  ( why so is a long
> history which I will not go into here) and that is a bit to slow for
> my needs. On my present setup [Twisted and XMLRPC ]it takes close to
> 200 ms to perform one transfer. But since that includes setting up and
> tearing  down the connection I thought I'd try doing something simpler
> so I wrote a server and a client using socket.

> I was surprised to find that the performance was equal to what
> Twisted/XMLRPC did. Around 200 ms per set, not significantly less.

That should tell you two things:
   * Twisted/XMLRPC is as efficient as you can hand craft. (which is a
     good use reason for using it).
   * That what you're measuring is overhead - and most likely of setup.

I'd measure the ping time between your two hosts. Why? TCP is not the
fastest protocol in the world. If you're measuring the whole
connection, you're dealing with a number of TCP messages:
   * Client -> SYN
   * Server -> SYN ACK
   * Client -> ACK
   * Client -> DATA (Assume data fits inside one message)
   * Server -> ACK
   * Client -> FIN
   * Server -> FIN ACK
   * Server -> FIN
   * Client -> FIN ACK
(Based on Fig 18.3, Steven TCP/IP Ill, Vol 2)

That's 9 round trips. 200ms / 9 == 22.2 ms

*IF* your ping time is close to this, then what you're really measuring
is TCP setup/teardown latency, not python latency. (*IF* you're on a
LAN and the latency is around that I'd suggest that you may have
discovered a local network problem) 

If your ping time is significantly lower -  eg you're running on
localhost - I'd suggest you translate your code to C (and/or post
your code), and repeat the same tests. So far you haven't shown
that python is slow here, just that something that you're measuring
causes it to be 200ms whether you use Twisted or not. (So you HAVE
shown that twisted isn't slow :-)

Another issue might be how you're measuring the latency - especially
whether if you're including startup of python in the 200ms or not!

Regards,


Michael.
-- 
Michael.Sparks at rd.bbc.co.uk, http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This message (and any attachments) may contain personal views
which are not the views of the BBC unless specifically stated.




More information about the Python-list mailing list