System Design Basics
System design is a structured conversation: clarify requirements, estimate scale, draw boxes, choose data stores, then deep-dive on failure modes.
Introduction
System design is a structured conversation: clarify requirements, estimate scale, draw boxes, choose data stores, then deep-dive on failure modes. For TechLearningPRO Orders on Spring Boot 3 / Java 21, that conversation turns into concrete choices — Postgres for the ledger of checkouts, Redis for hot SKU reads, Kafka for async fulfillment events, and an API gateway for auth and rate limits.
Interview whiteboards and production RFCs share the same vocabulary: RPS, p99, consistency, caching, partitioning. The difference is that Orders must ship — estimates drive pool sizes, topic partitions, and SLO alerts, not just slides.
This lesson gives you the repeatable template used for both senior interviews and Orders architecture reviews.
Purpose of this lesson
Apply a seven-step system-design template to TechLearningPRO Orders so estimates, APIs, and failure plans stay explicit under Boot 3.
Understanding the topic
Interview-and-real-life template — same steps, different fidelity.
- 1. Clarify — functional + non-functional (latency, durability, compliance).
- 2. Estimate — RPS, storage growth, bandwidth, peak vs average.
- 3. High-level — clients → gateway → Orders → DB / cache / queue.
- 4. Data model — schema, indexes, partitioning keys.
- 5. APIs — endpoints, idempotency keys, error envelopes.
- 6. Deep dives — cache invalidation, outbox, search, ML where relevant.
- 7. Ops — failures, monitoring, deploy/rollback.
Step-by-step explanation
- Write Orders FR/NFR: place order, cancel, list history; p99 < 300ms for GET; strong consistency on payment confirm.
- Estimate Black Friday: 2k place-order RPS peak, 50M order rows/year, average payload 2 KB.
- Draw boxes: CDN → Gateway → Orders pods → Postgres primary/replica → Redis → Kafka.
- Define
POST /api/orderswith Idempotency-Key and problem-details errors; document failure paths.
Informative example
Orders capacity sketch (interview-grade, production-useful).
// Back-of-envelope for TechLearningPRO OrdersPeak place-order RPS: 2_000Avg request size: 2 KB → ingress ≈ 4 MB/sOrders retained 3 years: ~150M rowsRow width ≈ 500 B → ~75 GB + indexes (~2×) ≈ 150 GBPostgres: primary + 1 replica; partition by created_month if scans hurtRedis: sku:{id} TTL 5m; cache hit target ≥ 90% on catalog readsKafka: orders.placed, 12 partitions, retention 7dBoot 3 pods: HPA on CPU + p99 latency; Java 21 virtual threads for I/O fan-out
Real-world use
A TechLearningPRO architecture review once approved 'just add Redis' without RPS math. Under a flash sale, cache stampede hit Postgres and checkout p99 spiked to 8s. Re-running estimates forced a request coalescing lock, a higher Redis TTL for immutable SKU fields, and gateway rate limits — the same steps a good system-design interview would have surfaced.
Security implications
Scale designs must not weaken tenancy or auth.
- Partition and cache keys include tenant/org where data is private.
- Gateway auth before fan-out; never expose internal service ports publicly.
- Keep credentials in env/secret stores — never in diagrams pasted into tickets as real values.
Best practices
- Always state assumptions and units (RPS, GB, ms).
- Prefer boring technology that the team can operate (Postgres + Redis + Kafka).
- End every design with monitoring: SLOs, alerts, and a rollback story.
Common mistakes
- Jumping to microservices before a single Orders bounded context is clear.
- Ignoring write path consistency while over-optimizing read caches.
- Designing for average load and melting on peak.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat is the first step in a system design interview?+
Answer
2IntermediateQuestionWhy estimate scale early for Orders?+
Answer
3IntermediateQuestionHow do you handle peak vs average traffic?+
Answer
Hands-on exercise
Lab. Design Orders for 10× Black Friday. Deliver: (1) FR/NFR list, (2) capacity sheet, (3) sequence diagram for idempotent place-order, (4) three failure modes with mitigation. Timebox 45 minutes; present trade-offs out loud.
Summary
Use the seven-step template for interviews and Orders RFCs alike. Next: turn estimates into a repeatable backend optimization playbook.