Re: [photon.users] Persistence for Multiple Children Processes
- Loic d'Anterroches
- 2011-02-26 @ 20:20
> When running multiple children workers for handling web requests,
> should the same user be routed to the same child process every time?
No, the routing is handled by ZeroMQ in a round robin manner. You can
plug a queue between the handlers and Mongrel2 to do process locality,
but I do not think this is worth it at the moment.
> For example, in the 30 line chat example, when running with 3
> children processes the chat example doesn't work because the same
> user can be routed to a different child process every time.
> This is because the in-memory "static $user_list" is different for
> each child process. Changing this array in one child process doesn't
> change it for the others.
Sure, this is why you must run with only one child for such simple
example. But, you can create a background task which will store the list
for you, a kind of memcached. This way you can access it from other
Look at the "memcached" example.
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