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

Stephen shriek at gmx.co.uk
Thu Nov 15 03:43:15 EST 2001


Thanks for the help, Cezary 

> >>But when NUMTHREADS = 20, half the threads die with this error :
> >>Unhandled exception in thread:
> >>Traceback (most recent call last):
> >>  File "<stdin>", line 6, in send_request
> >>  File "<string>", line 1, in connect
> >>socket.error: (10061, 'Connection refused')
> 
> If you are has clients and a server on the same machine, it is possible, 
> that server it does not have enough time to accept connections on a 
> listen socket. 

If I understand you correctly, then the server receives a 
request, creates a thread to deal with it. But the server
is so busy creating threads to deal with incoming requests,
that some other requests are ignored.

> By default only 5 connections can wait to be accepted - 
> if more appears, they are refused by your operating system. You can 
> raise this number, but there are limits on some OS-es.
>
> So, for really testing server you should launch clients from another 
> machine(s).

Sorry, you've lost me here. If the server can't generate 
threads quick enough to deal with the incoming connections,
how will moving the clients to another machine give the
server more time (except perhaps in introducing a network
delay) ?


> For building high-performance server check:
> http://www.nightmare.com/medusa/
> 
> Medusa combines asyncore with threads for optimal performance.

I had found the asyncore/asynchat method a little strange
but just downloaded the medusa package and there's a lot of
good documentation in the source. The included chat_server 
example looks like a good starting point. Will try that.

Sam also provides a great page of reference material. Excellent.

Stephen.



More information about the Python-list mailing list