[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Luarocks-developers] [ANN] lua-llthreads 1.0
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Mon, 11 Apr 2011 23:38:19 -0700
On Monday 11, joshua simmons wrote:
> On Tue, Apr 12, 2011 at 4:13 PM, Robert G. Jakabosky
>
> <bobby@sharedrealm.com>wrote:
> > On Sunday 10, joshua simmons wrote:
> > > Cool benchmarks. Cool release.
> >
> > Thanks, and thank you for coming up with name ideas for the project.
> >
> > > I'll have to have a play some time.
> >
> > When you have some time and if you are interested I have an idea on how
> > to add
> > thread support to your mongrel2 lua handler. Basically the main thread
> > would
> > act as the request load balancer and spawn X child threads to run the
> > handler
> > code. The balancer thread would pull requests from mongrel2 and push
> > then to
> > the child handlers. The child handlers would be able to send responses
> > directly back to mongrel2 without having to route them back through the
> > balancer thread. For "chat server" like handlers they would need to have
> > a way to share messages between the child handlers, this shouldn't be to
> > hard to
> > do but would require the handler to be multi-thread aware.
> >
> > For handlers that don't need or want to be multi-thread, they could work
> > like
> > normal and run in the main thread (i.e. without the extra balancer hop
> > for requests).
> >
> > --
> > Robert G. Jakabosky
>
> Would it not be easier to have each thread create their own zmq socket and
> connect to the server directly? Unless you need magic balancing stuff, in
> which case might a zmq device be more suited?
If all the HTTP requests from mongrel2 come in only one zmq message, then one
of the existing zmq queue devices would work. But for
WebSockets/JSSocket/etc.. the balancer would need to remember which child
handler is in charge of that client's connection. For some handlers that
might not be required a requirement. When handler starts it can select what
type of balancing/no-balancing it needs, and how many child threads it would
like.
Hmm, this type of mongrel2 request balancer could be made more generic to work
with any mongrel2 handler. But it would be nice to be able to easily
customize how the balancer works to fit the needs of the handler.
--
Robert G. Jakabosky