Why this matters
Every design question tests the same building blocks. Knowing them well lets you spend interview time on the interesting part, the trade-offs, instead of reinventing basics.
Building blocks
| Block | Use it to | Trade-off |
|---|---|---|
| Load balancer | Spread traffic across stateless app servers | Needs health checks; sticky sessions complicate scaling |
| Cache (CDN, Redis) | Serve hot reads fast | Staleness, invalidation, key scoping |
| Read replicas | Scale reads | Replication lag: a user may not see their own write |
| Partitioning / sharding | Scale writes and storage | Cross-shard queries and rebalancing are hard |
| Queue | Absorb bursts, decouple slow work | Eventual consistency; idempotency required |
| Object storage | Files, media, documents | Not a database; list operations are slow |
| Search index | Full-text and faceted search | A second copy to keep in sync |
| Vector index | Similarity search over embeddings | Approximate; filtering and updates need care (8.4) |
Consistency in plain words
- Strong consistency: every read sees the latest write. Simple to reason about; costs latency and availability across regions.
- Eventual consistency: reads may be stale briefly. Fine for feeds and counters; not for balances.
- CAP: during a network partition, a distributed store must choose between consistency and availability. Most real decisions are about latency versus consistency even without partitions.
- Read-your-writes: route a user's reads to the primary for a short time after they write.
Back-of-the-envelope estimation
1M daily active users × 20 requests/day = 20M requests/day
20M / 86,400 s ≈ 230 requests/s average; peak ≈ 3–5× → ~1,000 requests/s
Each stores 2 KB → 40 GB/day → ~15 TB/year
If each request makes one 2 s model call at 1,000 req/s → ~2,000 concurrent model calls
→ check the provider's rate limits and your budget before anything else
The last line is the AI twist: model latency and rate limits, not your servers, are usually the binding constraint (Little's law).
Common mistakes
- Jumping to microservices, Kafka and Kubernetes for a system with 50 users.
- Ignoring the data model; most scaling problems are data problems.
- Forgetting failure: what happens when the cache, the queue or the provider is down?
Interview follow-ups
- "How would you scale this 10×?" Find the binding constraint first (DB writes, model rate limits, a hot table), then the cheapest fix: caching, read replicas, async processing, partitioning by tenant, provider quota increases.
- "Monolith or microservices?" Start with a modular monolith; split a service out when it needs independent scaling, deployment or ownership, and pay the network and consistency costs knowingly.
- "How do you keep a search index in sync with the DB?" Change data capture or an outbox → queue → indexer, idempotent upserts, periodic reconciliation.
Check yourself
A user updates their profile and immediately sees the old version. Why, and what do you do?
Their read went to a replica that hadn't caught up (replication lag) or hit a stale cache. Read from the primary for that user for a short window after writes (read-your-writes), and invalidate the cache key on update.
When is sharding worth its cost?
When a single primary can no longer handle write volume or data size even after vertical scaling, indexing, caching and archiving. Choose a shard key that matches access patterns (often tenant ID) to avoid cross-shard queries.
Build it
Estimate requests per second, storage per year and concurrent model calls for a "summarise every support ticket" feature at a company with 5,000 tickets a day.