Skip to content

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 ​

  1. Compose service definitions, networks, DNS, environment, health checks and named volumes
  2. NGINX reverse proxy, location blocks, upstream groups and proxy headers
  3. Round-robin routing, unavailable upstreams and passive failure behavior
  4. Stateless API instances versus persistent shared application state
  5. 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 ​

Built with VitePress · Notes © 2026 [Your Name]