advancedScenario-Based & System Design Questions
A `docker compose up --scale api=3` command succeeds but only one of the three replicas ever receives traffic.
If `ports:` includes a fixed host port mapping, only the first replica can bind it successfully (the others fail to bind but might still report as running depending on configuration), so all traffic naturally lands on the one bound replica. Confirm by checking each replica's actual listening state, and fix by removing the fixed host port mapping and placing a load balancer or reverse proxy (e.g., nginx, Traefik) in front of the replicas to distribute traffic across all of them.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response