I'm facing a problem with my Docker Compose setup where I have a Fastify application running with 5 replicas specified, but it seems like only 2 of those replicas are actually handling traffic. I've set up NGINX to route traffic from `localhost:80` to `fastify-app:3000`, but when I check the health endpoint, I only see two unique hostnames in the response instead of spreading the load across all 5 containers. Is this a known issue with Docker and NGINX, or am I missing something in my configuration? Any help would be appreciated!
2 Answers
Is your setup running in swarm mode? If not, Docker's load balancing may not work as you'd expect, since it doesn't evenly distribute requests across replicas unless it's in swarm mode. You might want to check the documentation on Docker's networking to confirm how replicas can be utilized effectively.
NGINX doesn't automatically balance the load; you'll need to explicitly configure it to load balance among your replicas. Typically, this involves setting up a round-robin method in your NGINX config so that it can distribute requests across the available services.
But my NGINX setup only references `fastify-app:3000`, which makes it seem like it only knows about one instance. How does it handle multiple replicas?

No, it's not in swarm mode. Could you point me to the documentation about that? I couldn't find anything detailed on Docker's site.