Why does mongrel2 use a PULL/PUB approach with zeromq and not a REQ/REP ?
On Oct 17, 2011, at 7:49 PM, James Ladd wrote:
> Why does mongrel2 use a PULL/PUB approach with zeromq and not a REQ/REP ?
http://mongrel2.org/static/mongrel2-manual.html
5.3.1 Socket Types Used
First, the types of ZeroMQ sockets used are a ZMQ_PUSH socket for messages
from Mongrel2 to Handlers, which means your Handler’s receive socket
should be a ZMQ_PULL. Mongrel2 then uses a ZMQ_SUB socket for receiving
responses, which means your Handlers should send on a ZMQ_PUB socket. This
setup allows multiple handlers to connect to a Mongrel2 server, but only
one Handler will get a message in a round-robin style. The PUB/SUB reply
sockets, though, will let Handlers send back replies to a cluster of
Mongrel2 servers, but only the one with the right subscription will
process the request.
I did read that and wondered if there was a 'deeper' reason than enabling a cluster. On Tue, Oct 18, 2011 at 1:51 PM, Nathan Duran <principal@khiltd.com> wrote: > > On Oct 17, 2011, at 7:49 PM, James Ladd wrote: > > > Why does mongrel2 use a PULL/PUB approach with zeromq and not a REQ/REP ? > > http://mongrel2.org/static/mongrel2-manual.html > > 5.3.1 Socket Types Used > > First, the types of ZeroMQ sockets used are a ZMQ_PUSH socket for messages > from Mongrel2 to Handlers, which means your Handler’s receive socket should > be a ZMQ_PULL. Mongrel2 then uses a ZMQ_SUB socket for receiving responses, > which means your Handlers should send on a ZMQ_PUB socket. This setup allows > multiple handlers to connect to a Mongrel2 server, but only one Handler will > get a message in a round-robin style. The PUB/SUB reply sockets, though, > will let Handlers send back replies to a cluster of Mongrel2 servers, but > only the one with the right subscription will process the request.
On Tue, Oct 18, 2011 at 1:55 PM, James Ladd <james.ladd@playup.com> wrote: > I did read that and wondered if there was a 'deeper' reason than enabling a > cluster. > > > On Tue, Oct 18, 2011 at 1:51 PM, Nathan Duran <principal@khiltd.com> wrote: >> >> On Oct 17, 2011, at 7:49 PM, James Ladd wrote: >> >> > Why does mongrel2 use a PULL/PUB approach with zeromq and not a REQ/REP >> > ? >> >> http://mongrel2.org/static/mongrel2-manual.html >> >> 5.3.1 Socket Types Used >> >> First, the types of ZeroMQ sockets used are a ZMQ_PUSH socket for messages >> from Mongrel2 to Handlers, which means your Handler’s receive socket should >> be a ZMQ_PULL. Mongrel2 then uses a ZMQ_SUB socket for receiving responses, >> which means your Handlers should send on a ZMQ_PUB socket. This setup allows >> multiple handlers to connect to a Mongrel2 server, but only one Handler will >> get a message in a round-robin style. The PUB/SUB reply sockets, though, >> will let Handlers send back replies to a cluster of Mongrel2 servers, but >> only the one with the right subscription will process the request. > As well as that, it means that requests are disconnected from replies. There can be any number of outgoing messages generated from any number of incoming requests (or none at all).
I'm looking forward to putting mongrel2 through its paces. Just wanted a bit of vision on its 'design'. Thanks. On Tue, Oct 18, 2011 at 3:20 PM, Josh Simmons <simmons.44@gmail.com> wrote: > On Tue, Oct 18, 2011 at 1:55 PM, James Ladd <james.ladd@playup.com> wrote: > > I did read that and wondered if there was a 'deeper' reason than enabling > a > > cluster. > > > > > > On Tue, Oct 18, 2011 at 1:51 PM, Nathan Duran <principal@khiltd.com> > wrote: > >> > >> On Oct 17, 2011, at 7:49 PM, James Ladd wrote: > >> > >> > Why does mongrel2 use a PULL/PUB approach with zeromq and not a > REQ/REP > >> > ? > >> > >> http://mongrel2.org/static/mongrel2-manual.html > >> > >> 5.3.1 Socket Types Used > >> > >> First, the types of ZeroMQ sockets used are a ZMQ_PUSH socket for > messages > >> from Mongrel2 to Handlers, which means your Handler’s receive socket > should > >> be a ZMQ_PULL. Mongrel2 then uses a ZMQ_SUB socket for receiving > responses, > >> which means your Handlers should send on a ZMQ_PUB socket. This setup > allows > >> multiple handlers to connect to a Mongrel2 server, but only one Handler > will > >> get a message in a round-robin style. The PUB/SUB reply sockets, though, > >> will let Handlers send back replies to a cluster of Mongrel2 servers, > but > >> only the one with the right subscription will process the request. > > > > As well as that, it means that requests are disconnected from replies. > There can be any number of outgoing messages generated from any number > of incoming requests (or none at all). >
On 2011-10-18 06:32, James Ladd wrote: > I'm looking forward to putting mongrel2 through its paces. Just wanted a > bit of vision on Also a request reply approach would lock the server as you always need a request then a reply, even if the handler crashes. So a PULL/PUB approach is more robust. loïc > On Tue, Oct 18, 2011 at 3:20 PM, Josh Simmons <simmons.44@gmail.com > <mailto:simmons.44@gmail.com>> wrote: > > On Tue, Oct 18, 2011 at 1:55 PM, James Ladd <james.ladd@playup.com > <mailto:james.ladd@playup.com>> wrote: > > I did read that and wondered if there was a 'deeper' reason than > enabling a > > cluster. > > > > > > On Tue, Oct 18, 2011 at 1:51 PM, Nathan Duran > <principal@khiltd.com <mailto:principal@khiltd.com>> wrote: > >> > >> On Oct 17, 2011, at 7:49 PM, James Ladd wrote: > >> > >> > Why does mongrel2 use a PULL/PUB approach with zeromq and not a > REQ/REP > >> > ? > >> > >> http://mongrel2.org/static/mongrel2-manual.html > >> > >> 5.3.1 Socket Types Used > >> > >> First, the types of ZeroMQ sockets used are a ZMQ_PUSH socket for > messages > >> from Mongrel2 to Handlers, which means your Handler’s receive > socket should > >> be a ZMQ_PULL. Mongrel2 then uses a ZMQ_SUB socket for receiving > responses, > >> which means your Handlers should send on a ZMQ_PUB socket. This > setup allows > >> multiple handlers to connect to a Mongrel2 server, but only one > Handler will > >> get a message in a round-robin style. The PUB/SUB reply sockets, > though, > >> will let Handlers send back replies to a cluster of Mongrel2 > servers, but > >> only the one with the right subscription will process the request. > > > > As well as that, it means that requests are disconnected from replies. > There can be any number of outgoing messages generated from any number > of incoming requests (or none at all). > >