send_ident and recv_ident for 2 servers in front of 2 handlers
- From:
- Loic d'Anterroches
- Date:
- 2011-07-06 @ 09:23
Hello,
Just a not so short confirmation request. From the documentation I can read:
> send_ident: This is an identifier (usually a UUID) that will be used
> to register the send socket. This makes it so that messages are
> persisted between crashes.
>
> recv_ident: This is another UUID if you want the receive socket to
> subscribe to its messages. Handlers properly mention the send_ident
> on all returned messages, so you should either set this to nothing
> and don’t subscribe, or set it to the same as send_ident.
send_ident is effectively used to set the identity of the PUSH socket
for the message coming out of Mongrel2.
but recv_ident is not a socket identity, only a subscription identity,
right?
So, supposing we have 2 Mongrel2s in front listening on IPs A and B
(M2-A and M2-B), with 2 handlers (H1 and H2) connected to the two
Mongrel2s. That is, M2-A and M2-B are both SUBscribing on the PUB socket
of H1 and H2, and, H1 and H2 are both PULLing from the PUSH sockets of
M2-A and M2-B.
+------+ +------+
| M2-A | | M2-B |
+------+ +------+
| |
\________________/
|
_______|______
/ \
| |
+------+ +------+
| H1 | | H2 |
+------+ +------+
Yes, I am not an ASCII art wonder kid.
To avoid mixing of messages, that is H1 publishing and both M2-A and
M2-B forwarding to the client (in case of each of them get an open
connection with the same id, which if they started about at the same
time is really possible) we need to have:
Config M2-A:
handler_m2a = Handler(
send_spec='tcp://internalm2a:9997',
send_ident='m2a-uuid-for-this-handler',
recv_spec='tcp://internalm2a:9996',
recv_ident='m2a-uuid-for-this-handler'
)
Config M2-B:
handler_m2b = Handler(
send_spec='tcp://internalm2b:9997',
send_ident='m2b-uuid-for-this-handler',
recv_spec='tcp://internalm2b:9996',
recv_ident='m2b-uuid-for-this-handler'
)
This way, when H2 get a message from M2-A, it sends back with the
m2a-uuid and M2-B will not get it because it is not subscribed to it. Right?
In my tests I have two independant systems with only the DB being the
"shared" state. But this requires managing two configuration sets for
both Mongrel2 and the handlers. With this approach, the handlers have
only a single configuration, they just receive requests from two
differents sockets (or even more) instead of one. Of course it means I
need to improve my framework to connect to more than one Mongrel2, but
this is not that hard.
Sorry for the long message...
loïc
--
Indefero - Project management and code hosting - http://www.indefero.net
Photon - High Performance PHP Framework - http://photon-project.com
Céondo Ltd - Web + Science = Fun - http://www.ceondo.com