Inkwell Blogs pages now show related posts. The query behind them is slow, about 60 ms, mostly spent waiting on disk. Since it shipped, about one page in four fails with "too many connections", while the database's CPU sits at about half.
What it does
- Read: a reader opens a post, with its related posts.
- Write: an author edits a post.
Workload
A steady 4 000 rps, 95% reads / 5% writes, for 15 seconds, over 100 000 posts.
How to build it
The app tier is fixed: eight medium replicas behind a load balancer. The query time is fixed too. What you choose is the database: its tier and its read replicas. Each node accepts a limited number of connections:
| Tier | Connections per node | Price per node |
|---|---|---|
| Small | 100 | $0.12/h |
| Medium | 200 | $0.30/h |
| Large | 400 | $0.70/h |
| XLarge | 800 | $1.50/h |
- Build the path: client, load balancer, app server, database. Run it as it is.
- How many queries are running at once? Multiply the queries per second by how long each takes.
- Give the reads enough connections, for as little as you can.