SocketServer max connections

Laszlo Nagy gandalf at shopzeus.com
Wed Aug 27 13:22:05 CEST 2008


Guilherme Polo wrote:
> On Mon, Aug 25, 2008 at 7:20 AM, Ken Seehart <ken at seehart.com> wrote:
>   
>> I'm using SocketServer to implement a local server that serves comet
>> long-polling connections.
>>
>> How do I increase the maximum number of open connections?  Currently it is
>> limited to about 8 I think.  More than that and it seems to block on opening
>> more connections until one of the other connections releases.
>>     
>
> You need to change request_queue_size in your subclass, supposing you
> are directly or indirectly using a tcp server.
> The default is 5, rather low. The first attempt you can do is using
> the socket.SOMAXCONN value, but depending on your system you can set a
> number much higher than that one given by socket.SOMAXCONN.
>   
Also be aware that "request_queue_size" determines the max. number of 
incoming connections that are waiting in a queue to be accepted by the 
server. After the server calls accept() on the server socket, the 
connection is removed from the queue and a new client socket is created. 
The actual communication is done through the client socket(s). The 
number of open client sockets is independent of the request queue size. 
In other words, if you accept incoming connections instantly and then 
process clients in parallel, then probably you do not need to increase 
the queue size. (Maybe you already knew that?)

Best,

   Laszlo




More information about the Python-list mailing list