Skip to content

System Design Basics

Sure! Here are basic System Design notes written in clean, structured Markdown syntax — perfect for interviews or quick revision.


🏗️ System Design Basics


📘 1. What is System Design?

System Design is the process of defining the architecture, components, modules, interfaces, and data flow for a large-scale software system.

It focuses on how to build scalable, reliable, and maintainable systems that can handle millions of users efficiently.


🧩 2. Key Goals of System Design

  • Scalability → Handle increasing load (users, traffic, data).
  • Reliability → Continue functioning even with failures.
  • Availability → Keep the system accessible most of the time (e.g., 99.99%).
  • Maintainability → Easy to update, debug, and improve.
  • Performance → Fast response times, efficient resource usage.

⚙️ 3. Core Components of a System

ComponentDescription
ClientThe user interface or application making requests (browser, mobile app).
API GatewayEntry point for client requests — routes traffic to backend services.
Application ServerRuns business logic (e.g., Node.js, Django, Spring Boot).
DatabaseStores structured or unstructured data (SQL or NoSQL).
CacheTemporary high-speed storage (e.g., Redis, Memcached) to reduce DB load.
Load BalancerDistributes requests evenly across multiple servers.
Message QueueDecouples components and handles async tasks (e.g., Kafka, RabbitMQ).
CDN (Content Delivery Network)Delivers static content closer to users to reduce latency.
Monitoring & LoggingTools to track system health and diagnose issues (e.g., Prometheus, ELK).

🗂️ 4. Types of Databases

TypeUse CaseExample
SQL (Relational)Structured data, strong consistencyPostgreSQL, MySQL
NoSQL (Document)Unstructured, flexible schemaMongoDB, DynamoDB
Key-Value StoreFast lookups, cachingRedis, Memcached
Wide Column StoreAnalytics, big dataCassandra, HBase
Graph DatabaseRelationships, social networksNeo4j

⚖️ 5. Scaling Strategies

1. Vertical Scaling (Scaling Up)

  • Add more CPU/RAM to a single machine.
  • ✅ Easy to implement
  • ❌ Hardware limits and cost grow fast

2. Horizontal Scaling (Scaling Out)

  • Add more servers to handle traffic.
  • ✅ Better fault tolerance
  • ❌ Requires load balancing and distributed data management

📡 6. Load Balancing

Goal: Distribute incoming traffic across multiple servers.

Common Algorithms

  • Round Robin – Sequential distribution
  • Least Connections – Send to server with fewest active connections
  • IP Hashing – Based on client IP
  • Weighted Round Robin – Servers get different weights
  • Nginx
  • HAProxy
  • AWS Elastic Load Balancer (ELB)

⚡ 7. Caching

Why?

Reduce latency, DB queries, and improve performance.

Types

  • Client-side cache: Browser/local storage
  • Server-side cache: Redis, Memcached
  • CDN cache: Static content caching

Cache Invalidation Strategies

  • Write-through: Write to cache and DB simultaneously
  • Write-around: Write only to DB, cache updated on next read
  • Write-back: Write to cache, persist to DB later

📬 8. Message Queues & Asynchronous Processing

Used to decouple services and handle background jobs.

Examples

  • Kafka
  • RabbitMQ
  • AWS SQS

Use Cases

  • Sending emails or notifications
  • Processing uploads
  • Logging or analytics pipelines

🧱 9. CAP Theorem

PropertyMeaning
C - ConsistencyEvery read receives the latest write or an error.
A - AvailabilityEvery request receives a non-error response.
P - Partition ToleranceSystem continues to work despite network failures.

⚠️ In a distributed system, you can only guarantee two of the three (CA, CP, or AP).


🧭 10. Design Patterns for System Design

PatternDescription
MicroservicesBreak system into small independent services.
MonolithicSingle large codebase (simple but harder to scale).
Event-drivenComponents react to events asynchronously.
CQRSSeparate read and write models for performance.
Pub/SubPublishers broadcast messages; subscribers listen.

📈 11. Common Design Topics for Interviews

SystemConcepts to Know
URL Shortener (e.g., TinyURL)Hashing, Database indexing, Cache
Instagram / Twitter FeedSharding, Caching, Queueing
Chat App (e.g., WhatsApp)WebSockets, Message queues, Delivery status
E-commerce PlatformInventory management, Database design, Payment flow
Video Streaming (e.g., YouTube)CDN, Chunking, Adaptive bitrate streaming
Search AutocompleteTrie, Caching, Debouncing

🧮 12. Key Metrics to Monitor

  • Latency (ms) – Response time
  • Throughput (req/sec) – Number of handled requests
  • Availability (%) – Uptime reliability
  • Error Rate (%) – Failed requests
  • Scalability – Performance under load

🧠 13. Step-by-Step Approach to a System Design Interview

  1. Clarify requirements → Functional + Non-functional
  2. Estimate scale → QPS, data size, users
  3. Design high-level architecture → Components & data flow
  4. Define database schema → SQL/NoSQL choice
  5. Plan scaling & fault tolerance
  6. Discuss trade-offs → Consistency vs availability, cost vs performance
  7. Summarize the design visually or verbally

🧩 14. Tools & Technologies to Know

  • Frontend: React, Next.js, REST, WebSockets
  • Backend: Node.js, Nest.js, Express, Spring Boot
  • Databases: MongoDB, PostgreSQL, Redis
  • Cloud & DevOps: AWS, Docker, Kubernetes
  • Monitoring: Grafana, Prometheus, ELK Stack

🏁 15. Final Tips

  • Always start simple, then iterate into scalability.
  • Be explicit about assumptions (users, requests/sec, data size).
  • Use diagrams — even rough sketches help a lot.
  • Show trade-off thinking (cost, latency, complexity).
  • Practice explaining designs for common systems.