passenger icon indicating copy to clipboard operation
passenger copied to clipboard

Atomically spawn multiple processes

Open FooBarWidget opened this issue 9 years ago • 6 comments

Apps that have sticky session enabled suffer from an interesting problem: while processes are started, clients are routed to currently available processes, causing many clients to stick to those first few processes. Because of the sticky sessions, those clients are never balanced to the other processes.

A typical example is described at the Passenger mailing list:

  1. A user has ~500 people connected to the webapp and a reboot happens
  2. Nginx restarts, passenger restarts
  3. 2-4 passenger processes are up, automatically ~500 people are assigned to those 2-4 processes
  4. 28-30 processes are then started with 1 session on each, which makes them kind of useless
  5. Those 2-4 processes can’t keep up with the load and the webapp isn’t responsive for those people (which is like 95% of the current traffic)

One solution is to add an option for making the spawning of multiple processes "atomic": Passenger should wait until the min_instance threshold is reached before attaching all those processes. The boot time would be slower but the app would be usable after a reboot.

FooBarWidget avatar Dec 10 '14 12:12 FooBarWidget

The hypothesized problem turned out to be a red herring. The real cause is much simpler, as is the solution. See #1322.

FooBarWidget avatar Dec 18 '14 16:12 FooBarWidget

I compiled Passenger with the fix reported on #1322 and we’re using it in production, load balancing is working fine.

But when we're deploying and restarting Nginx this issue still happens. Everybody connects to the 2-3 processes that are up and it slows down the app. For now, we kill processes manually when this happens and people are correctly load balanced to other processes.

Long story short : #1322 helps #1317, but doesn’t fix it. An ideal solution would still be to wait until all processes are spawned before load balancing sessions.

Thank you

charlesvallieres avatar Dec 18 '14 19:12 charlesvallieres

I will release 4.0.56 anyway, which contains #1322. That should at least help you guys in the short term.

FooBarWidget avatar Dec 18 '14 19:12 FooBarWidget

Yes, thank you! I may have some time to look into this issue (or we may build a quick and dirty work around). I'll post my findings here if this happens.

charlesvallieres avatar Dec 18 '14 19:12 charlesvallieres

Hey @FooBarWidget, is there any news on this? We're still manually killing the first 3-4 processes that spawned to load balance correctly :)

Thanks!

allaire avatar Aug 10 '15 23:08 allaire

Hey got the same problem as allaire. Passenger-Version: 6.0.8 Still no other way than killing first process manually?

JD2k avatar Aug 23 '21 12:08 JD2k