Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services)

brueckd at tbye.com brueckd at tbye.com
Wed Nov 14 12:16:02 EST 2001


On 14 Nov 2001, Stephen wrote:

> I've been trying to benchmark socket server and can't seem
> to get it past serving 200 requests per second.
[snip]

Thread-per-request servers can't scale up too high (although it might be
interesting to see what stackless + microthreads would do). You'll need to
use the asynchronous I/O support (see the select module for lower level
stuff, asyncore/asynchat for slightly higher stuff). If you don't want to
build it yourself then you should consider some of the third-party
frameworks like Twisted.

Also, a lot of the server tuning guidelines that apply to things like
Apache can be helpful to you.

> Am-I-asking-too-much-of-Python-ly-your's,

Not necessarily. If your program is mostly I/O bound then the slowness of
Python (vs. C for example) becomes less of a factor. A Python server we're
building at my work is tuned towards data throughput (and not so much
towards connections per second, but still shoots for several hundred), and
it easily pushes 1 Gbps on a single CPU P3-933. :)

-Dave





More information about the Python-list mailing list