Lecture 02. Docker Compose, NGINX and horizontal scaling
Week 3 · Syllabus and preparation from the course outline; no study date or personal lecture notes have been recorded.
Business scenario
A second Order API replica is launched. Every customer must see the same order data regardless of the replica receiving the request.
Topics to cover in this class
- Compose service definitions, networks, DNS, environment, health checks and named volumes
- NGINX reverse proxy, location blocks, upstream groups and proxy headers
- Round-robin routing, unavailable upstreams and passive failure behavior
- Stateless API instances versus persistent shared application state
- PostgreSQL schema ownership and migrations; multi-container troubleshooting
Learning objectives
- Deploy a reproducible five-service development environment.
- Demonstrate client routing through one gateway to two API instances.
- Explain why in-memory state breaks horizontal API scaling.
Live demonstration checklist
- Route /orders and /restaurants via gateway; show different instance IDs on repeated calls.
- Persist an order, restart the stack, retrieve the record from either Order API instance.
Preparation and optional written reflection (ungraded)
Reading focus: Read a short section of the NGINX load-balancing guide; distinguish load distribution from data consistency. Optional individual reflection: Why does placing two API containers behind NGINX not automatically make the system fault tolerant?
Study materials: official docs, websites and YouTube
Official | Compose Quickstart | https://docs.docker.com/compose/gettingstarted/ Hands-on Compose YAML and service startup
Official | Compose networking | https://docs.docker.com/compose/how-tos/networking/ DNS names and container-to-container traffic
Official | NGINX reverse proxy | https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ proxy_pass and header forwarding
Official | NGINX HTTP load balancing | https://nginx.org/en/docs/http/load_balancing.html Round-robin and passive failover
YouTube | Configure NGINX as a Reverse Proxy (NGINX) | https://www.youtube.com/watch?v=lZVAI3PqgHc Direct configuration demonstration