I’m a bit pressed for time but want to throw out a few incomplete
You will have a very difficult time doing IPC between worker processes
unless you do IPC over a unix domain socket (and even then it sorta
IMHO this is sub-optimal as this module has the ability to block the
webserver on long running operations.
An example to frame this in would be preserving session state without a
third party process like redis or memcached. Since you have LUA built,
may see better performance and footprint if you do the following:
- Create a shared dictionary at nginx init (example,
This dictionary will be shared across all nginx worker processes in
- Create an internal only LUA handler for setting/getting data out of
- Implement some sort of locking mechanism in the above handler.
- Use something like $r->internal_redirect to get/set data in and out of
the above lua handler.
In this way you can preserve something like session data across all
workers. You could use something like Thaw and Freeze to serialize perl
data types as well.
I haven’t thoroughly thought through this design so there may be some
‘gotchas’ but my hope is to save you a few days of Perl IPC Frustration.
The obvious caveat here is avoiding memory bloat by being conservative
the amount of data you jam into shared dicts. I foresee you will have
issues using internal_redirect (I dont have the docs in front of me), so
you may need to be creative here as the API is limited. I have a soft
for perl but this module leaves a lot to be desired. You must be
in your design as to what will and will not block.
As a final thought, have you looked into
http://zzzcpan.github.io/nginx-perl/ ? this project appears to be in
of love and if memory serves makes some changes to nginx core which
prevents upgrades, however, this project seems to support a lot of async
perl operations that would make life easier.
On Wed, May 14, 2014 at 10:06 AM, David Coutadeur