I have a group of several web applications in docker swarm containers. Some of them have a single instance, some multiple, and that situation may change dynamically, based on our needs (application serve different purposes). I also have a single nginx-based facade which I want to organize a round-robin over all of these instances. It is configured like this:
upstream all {
server a;
server b;
server c;
}
server {
listen 80;
location /all/ {
proxy_pass http://all/
}
}
For example, services a and c have one instance each, while service b has 2 instances (2 containers). If I start accessing http://host/all/ the sequence in the round robin is this: a, b(1), c, a, b(2), c, .. and so on. I would like to make it instead: a, b(1), b(2), c and so on.. So that I only get back to a after I've got all instances of all other services.
And, if we want to upscale a to have 3 instances, the sequence should then become a(1), a(2), a(3), b(1), b(2), c - and back to a(1) and so on.
Is it possible? And how?
PS. In case you are wondering why I would need this: each service has a uniform endpoint that returns health and status information and I'd like to build a dashboard that circles over all the instances of all services and displays a single status page "who is doing what".
PPS. My backup plan is to keep calling the API and counting instances until ALL of the counters stop growing. But that means, if there is a significant imbalance (like 1 instance of everything and 50 instances of one), many services would have to answer many redundant times.