From: Daniel Bush Date: 2009-10-21T20:49:46+09:00 Subject: Re: ruby 1.8.6, threadpooling and blocking sockets - advice/help Brian Candler wrote: > Robert Klemme wrote: >> Frankly, I wouldn't invest that effort: every example in all programming >> languages I have seen has just a single acceptor thread. > > ...or else serializes them so that only one thread accept()s at a time. > For a proper example look at Apache with preforked workers, and the > AcceptMutex directive. > http://httpd.apache.org/docs/2.0/mod/mpm_common.html > Cool. Didn't even think to look at what the big boys do. Thanks for the pointer. > You could try the same approach, and use a ruby Mutex to protect your > socket#accept - but that could turn out to be more expensive than having > a single accept thread which dispatches to your worker pool, if you're > going to have a separate worker pool anyway. Yeah, I have a worker pool. I was sort of extrapolating from that and having an acceptor pool based around the socket in addition to the worker pool. I don't have a lot of experience with heavy traffic; but the (naive) motivation for this whole thing was to have one acceptor thread receiving while the other was pushing on the queue and then swapping over and over[1] -- at least to allow people to experiment with that sort of thing if they wanted to. But synchronisation issues with the extra thread might make things worse. I'm used to trying out duff ideas so heck maybe I might take a look at it at some point - if only to get a better feel for what's going on at that level. Cheers, Daniel Bush [1] actually, I naively wanted all the threads to block on the socket just like they would on a queue. oh well. -- Posted via http://www.ruby-forum.com/.