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

Jp Calderone kuran42 at yahoo.com
Thu Nov 15 14:26:30 EST 2001


If you're looking for maximum performance, dump threads.  SocketServer's
documentation itself points out that the synchronous implementation is
not the best way to go.

But before you abandon the SocketServer module, try twiddling the listen
parameter.  You can do this most easily by overriding the BaseServer 
method server_activate.  Try setting it at about the value of
NUMTHREADS.


Stephen wrote:

> [snip]

> 
> Results ~
> 
> When NUMTHREADS = 2, 200 requests are handled in < 0.5 secs
> When NUMTHREADS = 5, 500 requests are handled in 2.5 secs
> 
> 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')
> 
> and it just gets worse when NUMTHREADS = 50.
> 
> I'm guessing this means that the server is max'ed out and
> can't handle any more.
> 
> How should I handle this error ?  Yes, with a "try/except" 
> but what should the "except" do, because if the server is
> too busy, it's probably no point retrying immediately. 
> 
> So, you see, I was looking for something more immediate than
> SMTP, that also takes care of the message queueing. Writing
> code to manage the queue and buffering could be horrendous. 
> 
> Is there any way to get this up to say 1,000 requests/sec peak load ?
> 
> In reality, I'm going to want to put some Database query
> into the RequestHandler too so it'd be even slower. 
> Does this sound possible ?
> 
> Am-I-asking-too-much-of-Python-ly-your's,
> 
> Stephen
> 


-- 
1.79 x 10^24 furlongs per picofortnight - It's not just a good idea,
			It's the law!
--
  2:06pm up 12 days, 16:25, 2 users, load average: 0.00, 0.01, 0.01




More information about the Python-list mailing list