ποΈ System Design
Learning Objectivesβ
- Understand core system design goals: scalability, availability, latency, and consistency.
- Learn a repeatable interview framework: clarify, estimate, design, deep dive, summarize.
- Choose appropriate data stores, caching, and messaging patterns for real-world systems.
- Reason about trade-offs (CAP, consistency models, SQL vs NoSQL, caching vs freshness).
Prerequisitesβ
- Basic networking and HTTP knowledge
- Familiarity with databases (SQL/NoSQL) and basic DSA concepts
- Comfort with asynchronous programming and services
Difficulty Levelβ
- Intermediate β Advanced (varies by topic)
Estimated Reading Timeβ
Approximately 30β45 minutes for this overview; individual topic pages vary (15mβ3h each).
Mental Modelβ
Think of a system as a set of interacting components: clients, API surface, services, caches, data stores, and infrastructure (load balancers, CDNs, message brokers). Design is choosing the right components and connections to meet functional and non-functional requirements while keeping complexity manageable.
How to use this sectionβ
- Start with the high-level overview and follow the recommended order in the Table of Contents below.
- For interview preparation, practice the approach in βHow to Approach a System Design Interviewβ and run through mock designs.
- For production engineering, read the deep-dive pages (databases, sharding, caching) and pay attention to the "Trade-offs" and "Operational Concerns" subsections.
Quick Links (what to read first)β
- Clarify requirements and capacity estimation
- High-level design pattern and example architectures
- Data storage and consistency guide
One-line summary: Learn to design large-scale, reliable, and scalable systems β and to reason about the trade-offs interviewers care about.
π― What is System Design?β
System Design is the discipline of defining the architecture, components, interfaces, and data flow of a software system to satisfy a set of functional and non-functional requirements (scalability, availability, latency, consistency, cost).
Unlike a single algorithm problem, system design is open-ended: there is rarely one correct answer. The goal is to make reasoned trade-offs β balancing performance, reliability, complexity, and cost β and to communicate them clearly.
These fundamentals power every large product you use: the timeline that loads instantly, the payment that never double-charges, the video that streams to millions at once.
π§© How to Approach a System Design Interviewβ
Follow a repeatable framework so you never freeze on a blank whiteboard. Spend time proportionally β don't jump to databases before pinning down requirements.
flowchart TD
A[1. Clarify Requirements] --> B[2. Capacity Estimation]
B --> C[3. High-Level Design]
C --> D[4. Deep Dive into Components]
D --> E[5. Identify Bottlenecks & Trade-offs]
E --> F[6. Summarize & Justify]
A -.-> A1[Functional + Non-functional<br/>Scope in / out]
B -.-> B1[QPS, storage, bandwidth<br/>Read/write ratio]
C -.-> C1[Clients, API, services,<br/>data stores, cache, queues]
D -.-> D1[Data model, sharding,<br/>replication, algorithms]
E -.-> E1[Single points of failure,<br/>hotspots, scaling limits]
1οΈβ£ Clarify Requirementsβ
- Functional: what must the system do? (e.g., "shorten a URL", "post a tweet").
- Non-functional: how well? (availability, latency, consistency, durability, scale).
- Scope explicitly: state what is in and out of scope to bound the problem.
2οΈβ£ Capacity Estimation (Back-of-the-Envelope)β
- Estimate QPS (queries/sec), read:write ratio, storage growth/year, and bandwidth.
- These numbers justify later choices (caching, sharding, replication).
3οΈβ£ High-Level Designβ
- Draw the major building blocks: clients β load balancer β API/services β cache β databases, plus queues for async work.
- Define the API contract (endpoints, request/response) between components.
4οΈβ£ Deep Dive into Componentsβ
- Pick the 1β2 most interesting components and go deep: data model, sharding strategy, replication, consistency model, indexing, and algorithms.
5οΈβ£ Identify Bottlenecks & Trade-offsβ
- Find single points of failure, hotspots, and scaling limits.
- Discuss trade-offs explicitly (e.g., CAP theorem, strong vs. eventual consistency, SQL vs. NoSQL).
6οΈβ£ Summarize & Justifyβ
- Recap the design, restate key trade-offs, and note what you'd improve with more time.
π Fundamentals β Table of Contentsβ
Work through these in order. Each page is a focused deep-dive on one building block.
Core Scaling Building Blocksβ
- Scalability β vertical vs. horizontal scaling, stateless services
- Caching β cache patterns, eviction, invalidation, CDNs
- Load Balancing β algorithms, layers (L4/L7), health checks
Data & Storageβ
- Databases β SQL vs. NoSQL, indexing, when to use what
- CAP Theorem β consistency, availability, partition tolerance
- Sharding β partitioning strategies and hotspots
- Replication β leader/follower, multi-leader, quorums
- Consistency Models β strong, eventual, causal consistency
Communication & System Boundariesβ
- Message Queues β async processing, decoupling, delivery guarantees
- API Design β REST, gRPC, versioning, pagination
- Rate Limiting β token bucket, leaky bucket, sliding window
- Microservices β service decomposition, trade-offs vs. monoliths
Backend Engineering Conceptsβ
- Node.js
- Authentication/Authorization
- Validation
- Error Handling
- Rate Limiting
- Logging
- Monitoring
- Caching
- Queues
- Event Driven Architecture
- WebSockets
- gRPC
- API Gateway
- BFF (Backend for Frontend)
- Service Discovery
βοΈ Authoring Conventions (Read Before Contributing)β
Contributors: follow these conventions exactly so every page in this section stays consistent.
1. Front Matterβ
Every page must begin with YAML front matter containing at least title and sidebar_position:
---
title: Caching
sidebar_position: 3
---
titleβ human-readable page title (Title Case), shown in the sidebar and browser tab.sidebar_positionβ integer controlling ordering within this section. Do not change the pre-assigned positions (they lock the sidebar order).
2. Mermaid for Diagramsβ
Use fenced mermaid code blocks for all architecture and flow diagrams (Docusaurus renders them natively):
flowchart LR
Client --> LoadBalancer --> Service --> Cache
Service --> Database
3. Cross-Link Relative Path Styleβ
- Link between pages in this section with relative paths including the
.mdextension:[Caching](./caching.md). - Link to sibling concept folders with
../folder/README.md:[Hashing](../DSA/hashing/README.md). - End each page with a back-link footer:
[β Back to System Design](./index.md) Β· Β© sparshjaswal.
4. Page Structure (Recommended)β
Each fundamentals page should include: a one-line summary blockquote, Core Concepts, at least one mermaid diagram, Trade-offs / When to Use, and Related Topics.
π― Quick Interview Prep Checklistβ
- Always clarify functional and non-functional requirements first
- Do back-of-the-envelope capacity estimation
- Draw a clean high-level diagram before going deep
- Know when to cache, shard, and replicate β and why
- Be able to explain the CAP theorem and consistency trade-offs
- Discuss bottlenecks and single points of failure proactively
Note (AI-assisted draft): The following Interview Questions, Production Checklist, and Testing & Monitoring items are drafted to accelerate review. Please verify wording and add organization-specific links/runbooks.
Interview Questionsβ
- Walk me through how you would design a system to handle 10Γ traffic. What steps and trade-offs would you describe?
- How do you pick a shard key and how would you detect and mitigate hotspots?
- Describe a safe failover and promotion process for a leaderβfollower database cluster.
Production Checklistβ
- Capture expected peak QPS, read/write ratio, and storage growth; publish to the design doc
- Define SLOs and alerts for p50/p95/p99 latency, error rates, and saturation
- Provide runbooks for failover, rebalancing, and emergency rollback
- Ensure tracing, metrics, and structured logs are in place before production rollouts
Testing & Monitoringβ
- Load-test with realistic traffic shapes, including sudden spikes and sustained growth
- Run chaos experiments for node/network failures and validate automated recovery
- Monitor replication lag, cache hit ratios, and per-shard metrics; alert on skew/hotspots
π Related Topicsβ
- DSA (Data Structures & Algorithms) β data structures and algorithms
- Hashing β consistent hashing for sharding
- Heaps β priority queues in schedulers and rate limiters
β Back to Home Β· Β© sparshjaswal