Part 3 · 1 chapters · ~8 min

Backend System Design

The backend design round arc, requirements and non-functional targets, back-of-the-envelope estimation, API and data model first, high-level architecture, choosing two or three deep dives, scaling only where the numbers demand it, failure modes and operations, and prompts worked in outline (payments, URL shortener, rate limiter, chat, notification system, feed).

4

Estimation and prompts

code
back-of-envelope: a payments service
  2,000,000 transfers/day ÷ 86,400 s ≈ 23/s average; peak (salary day, 10×) ≈ 230/s
  each transfer: ~6 ledger rows × 200 B ≈ 1.2 KB → 2.4 GB/day → ~0.9 TB/year before indexes
  → one Postgres primary + replicas handles the writes; plan partitioning by month for history (Postgres P7)
  → the hard parts are correctness (idempotency, double-entry, reconciliation), not throughput
promptdeep dives worth choosingLearna
payments / walletidempotency keys, double-entry ledger, rail timeouts and unknown states, reconciliationLedgers, API Design P8, Workflows
rate limiteralgorithm choice, Redis Lua atomicity, distributed limitsBackend Algorithms P1, BSD P2
chatconnection gateway, fan-out, ordering per conversation, presenceBSD, Kafka
notification systempriority queues, provider failover, dedupe, user preferencesWorkflows, Kafka
news feedfan-out on write vs read, celebrity accounts, ranking cacheBSD, Redis
URL shortenerid generation (base62, collisions: birthday bound), cache, analyticsDiscrete P4, Redis
BACKEND SYSTEM DESIGN, THE ARC
requirements → numbers → simple design → deep dives → failure
requirementsfunctional + non-functionalestimatesQPS, storage, bandwidthhigh-level designclients, API, services, datadeep divesthe hard part, 2-3 of themfailure and operationswhat breaks, how you know
swipe the figure sideways, or tap expand for full screen
1/4
requirements
Separate functional ("send money to a bank account") from non-functional (99.95% availability, no double debits, p99 under 300 ms). The non-functional ones drive the design.
functional + non-functionalNFRs drive design