I've got a legacy web application, it sometimes crashes. Also, it have an application cache residing in the virtual space of the app itself - it can not share the cache data with other instances of the same app, and I can not do the needed modifications.
The app is kinda unstable, sometimes crashing and taking some time to recover. What I want is to launch two instances of the app, for example A and B, and then letting nginx do the rest. What I want is:
Upon launching, A will be the main server only (even of A and B are both up and running, all requests should go to A only!). When A crashes, nginx should switch for B only. When A recovers, and B still works, nginx should be STILL continuing to using ONLY B. That is, until B crashes too! After that, it should switch to A again and use it even if B recovered and is available again. That is, until A crashes... Well, you got the idea I guess =)
The "backup" directive seems not what I want, and all the other variants seems to just adjust the method of distribution of requests across both of upservers, without any way to actually block request from one or other temporarly (without the "disable" cause).
Is this not possible from only nginx configuration, or I've lost something?
UPD: I'm now thinking trying to play with set_peer_down from ngx_lua module on failures (see documentation here), but seems like a complex solution to a simple problem... Is it not possible to do without some programmatic solution?
0 Answers