On 8/5/13 4:33 PM, Sean Kelly wrote:
On Aug 4, 2013, at 12:38 PM, Marek Janukowicz <[email protected]> wrote:

I'm writing a network server with some specific requirements: - 5-50 clients 
connected (almost)
permanently (maybe a bit more, but definitely not hundreds of them) - possibly 
thousands of
requests per seconds - responses need to be returned within 5 seconds or the 
client will
disconnect and complain

Given the relatively small number of concurrent connections, you may be best 
off just spawning a
thread per connection.  The cost of context switching at that level of 
concurrency is reasonably
low, and the code will be a heck of a lot simpler than an event loop 
dispatching jobs to a thread
pool (which is the direction you might head with a larger number of 
connections).

I agree, with one important caveat: converting from a blocking thread per connection model to a non-blocking pool of threads model is often essentially starting over. Even at the 50 threads point I tend to think you've passed the point of just throwing threads at the problem. But I'm also much more used to dealing with 10's of thousands of sockets, so my view is a tad biased.

Reply via email to