I have a memory leak on one of my apps being served with nginx + passenger and a
min/max_instances 2 setting. Memory keeps growing up as time passes by, and this can be a problem on a machine with limited memory (eg Amazon Web Services) that can end up crashing badly.
Is there a way / trick to restart some passenger processes of the same app, either periodically or when memory reaches a certain threshold ?
Suppose I have an application group A that can start up to 2 processes A1 and A2. I'd like to restart A1 and A2 one at a time to ensure service continuity (this is not a zero-downtime deployment since it relies on the same unmodified app, but some way to purge the memory leak and restart a fresh process until I figure out the problem).
Eg suppose I have the following state:
Requests in queue: 0
* PID: 11124 Sessions: 0 Processed: 14638 Uptime: 1d 12h 31m 29s CPU: 0% Memory : 341M Last used: 24s * PID: 11131 Sessions: 0 Processed: 9323 Uptime: 1d 12h 31m 29s CPU: 0% Memory : 389M Last used: 24s
Process n°2 starts taking up a lot of memory (~400) so I'd like to restart it (and only this process) which should bring it back to 100MB ish, and I'd do the same with Process n°1 later
The memory leak takes some time to build and it would be best if I could restart only when detecting too high memory usage, but if I can schedule a process restart every night or so this could also work totally fine (eg restart process n°1 at 3am, then process n°2 at 4am)
Is there any signal I can send to this passenger group that would let me restart processes one by one ?