Routing to a certain worker

Maxim Dounin mdounin at
Mon Jul 23 19:15:06 UTC 2018


On Mon, Jul 23, 2018 at 01:53:21PM -0400, M.P. Ardhanareeswaran wrote:

> I understand the desire for worker processes to be symmetric.
> ProxyPass and upstream allow sticky session/session affinity 
> which does introduce some skew though mighty useful IMHO.  
> Do you have any thoughts about use of this?  
> I am very new to handler development in NGINX.  It appears that 
> the handlers cannot do this and is heavily discouraged.

Normally, if a module needs some information to be shared between 
worker processes, it uses shared memory zones:

Sticky sessions use shared memory and therefore do not introduce 
any inequalities between worker processes.  Many other modules, 
such as limit_conn and limit_req, do the same.

Unfortunately, your particular case as you've described it is 
different, as you are trying to open a database connection and 
keep it open for future requests.  Unless a connection is statless 
and can be re-opened on demand, this is won't be something 
possible to implement within nginx worker model, because there are 
no mechanisms to share connections between worker processes.

Maxim Dounin

More information about the nginx-devel mailing list