Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services)
Cezary Biernacki
cezary at bigfoot.com
Wed Nov 14 14:33:41 EST 2001
Scherer, Bill wrote:
> You've got a multithreaded client hitting a single threaded,
> synchronous server. You can do significantly better if you
> thread your server, or use asyncore (or a combination of the
> two).
The server is threaded to:
>>class RequestServer(SocketServer.ThreadingTCPServer):
>> allow_reuse_address = 1
>>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. 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).
For building high-performance server check:
http://www.nightmare.com/medusa/
Medusa combines asyncore with threads for optimal performance.
-
CB
More information about the Python-list
mailing list