Startup

Small startup

Nginx in front of two app servers and one PostgreSQL. The app tier scales; the database becomes the bottleneck.

Small startup running in the ServerSloth simulator

What this architecture teaches

Two app servers behind Nginx can handle far more traffic than one, so the obvious bottleneck moves — straight to the database, which everything still shares.

PostgreSQL runs only a handful of queries at once and accepts 100 connections by default. When queries arrive faster than it completes them, waiting queries hold connections until the limit is reached and new clients are refused with “sorry, too many clients already”.

Ways out: cache reads, add read replicas, put a connection pooler such as PgBouncer in front, or use a bigger instance.

What to look for

Components

Failure modes you will see