Limit (max) connections SimpleHTTPServer

Jean-Paul Calderone exarkun at
Mon Jun 15 15:30:55 EDT 2009

On Mon, 15 Jun 2009 12:14:28 -0700 (PDT), Daniel <daniel.watrous at> wrote:
>I would like to know if there is some way to limit the maximum number
>of connections to my SimpleHTTPServer.  I have built a system that
>sends out work from one box to worker boxes and am using
>SimpleHTTPServer to send the work.  The files are very large
>(sometimes as much as 20-30MB).  When the system gets backed up, there
>can be as many as 500 requests coming in.  After about 100
>connections, the whole system starts to get sluggish.  When they get
>over 250 or so some requests will begin to fail
>"error: (10054, 'Connection reset by peer')"
>or "error: (10053, 'Software caused connection abort')"
>Any help and suggestions appreciated.

For a server that has to deal with this kind of load, you might want to look
at Twisted instead of SimpleHTTPServer.  You can certainly impose a limit on
the number of connections SimpleHTTPServer handles at once, but you'll get
better performance with Twisted, due to less thread overhead and because you
probably won't have to impose such a limit, or if you do, it can be much

Check it out:


More information about the Python-list mailing list