Skip to content

Complete System Design Course: Scalable Architectures & Key Concepts

System Design: From Foundation to Scalable Architectures

This course provides a thorough introduction to system design, explaining the core concepts that allow applications to scale from serving 10 users to 10 million users simultaneously. The content covers the entire spectrum, from fundamental components to advanced architectural patterns.

1. Foundation & Core Components

What is System Design?

System design is the discipline of creating architectures that can handle massive user loads. It involves combining components (servers, databases, caches) to achieve a common goal of serving millions of users reliably and efficiently. For a broader overview of these principles, see System Design Basics: Scalability, Cloud Hosting & API Explained.

The Alien Bank Analogy

To understand system design concepts intuitively, the course uses a story of building a bank:

| Issue | Solution | System Design Concept | |-------|----------|----------------------| | Process is slow (10 mins/customer) | Improve cashier skills | Optimize code quality, LLD | | Customer count increasing | Add cash counting machine, forms | Vertical scaling (upgrade server) | | Customers still waiting for single counter | Add more cash counters | Horizontal scaling (add more servers) | | Data discrepancy between counters | Introduce centralized database | Centralized database architecture | | Underutilized counters | Add a middleman to distribute customers | Load balancer |

This analogy is further explained in Scalable System Design Explained Using a Restaurant Analogy.

Data-Intensive vs. Compute-Intensive Applications

  • Data-Intensive: Focus on moving data quickly (e.g., Instagram feeds, WhatsApp messages). Worries include read speed, storage safety, and handling high concurrent users. Solutions involve caching, replication, and sharding.
  • Compute-Intensive: Focus on heavy calculations (e.g., image processing, ML model training, simulations). Worries include computation speed, parallel processing, and cost reduction. Solutions involve optimizing CPU/GPU usage.
  • Key Trick: If time is lost in data movement, it's data-intensive. If lost in computation, it's compute-intensive.

2. Communication & APIs

DNS (Domain Name System)

DNS is a hierarchical system that translates human-readable domain names into IP addresses. It involves:

  • DNS Resolver: Provided by your ISP, initiates the process.
  • Root Servers: 13 logical servers that know the IP addresses of Top-Level Domain (TLD) servers.
  • TLD Server: Handles specific TLDs like ".com", knows the IP of the authoritative name server.
  • Authoritative Name Server: Stores the actual IP address of the domain (e.g., telesco.com).

Caching: Results are cached at the browser, OS, and DNS resolver levels to speed up subsequent requests.

Types of APIs

| API Type | Description | Use Case | |----------|-------------|----------| | REST | Stateless, uses JSON, most common | General web and mobile apps | | SOAP | Uses XML, legacy systems | Older enterprise applications | | GraphQL | Single endpoint, client defines query structure | Flexible data fetching | | gRPC | Uses Protocol Buffers, fast and small | Internal microservice communication | | WebSockets | Full-duplex, real-time communication | Chat, live notifications, gaming |

REST API Deep Dive

  • Methods: GET (retrieve), POST (create, returns 201), PUT (full update), PATCH (partial update), DELETE (remove).
  • Path Conventions: Use plural nouns (e.g., /users, /blogs).
  • Nested Resources: Use nesting for clear relationships (e.g., /blogs/{id}/comments), query parameters for complex filters or pagination.
  • Response Codes:
    • 200 OK, 201 Created, 204 No Content
    • 301 Permanent Redirect, 302 Temporary Redirect
    • 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found
    • 500 Internal Server Error
  • Best Practice: Always wrap responses in an object (e.g., {"users": [...]}) for future extensibility.

3. Data Storage

SQL (Relational Databases)

  • Structure: Tables, rows, columns, relationships via foreign keys.
  • Key Constraints: UNIQUE, NOT NULL, PRIMARY KEY, FOREIGN KEY, CHECK, DEFAULT.
  • Relationships:
    • One-to-Many: A user can have multiple orders.
    • Many-to-Many: Students and courses (requires a junction table).
    • One-to-One: A content table linking to separate video/audio/blog tables.
  • Use Case: Best for consistent, structured data with complex relationships (e.g., payment systems, transactions).

NoSQL Databases

  • Why NoSQL?: Easy to scale horizontally, schema-less (handles unstructured data), and faster for certain operations due to single document structure.
  • Types:
    • Key-Value (e.g., Redis): Simple data retrieval by a unique key. Good for caching, sessions, cookies.
    • Columnar DB (e.g., BigQuery, Redshift): Reads data column-wise instead of row-wise. Excellent for analytical queries and aggregations.
    • Graph DB (e.g., Neo4j): Nodes and edges with properties. Ideal for social networks, recommendation engines, and analyzing relationships.
    • Document DB (e.g., MongoDB, CouchDB): Stores JSON-like documents. Flexible and great for logging, user profiles, and content management.
  • Rule of Thumb: Use NoSQL when availability and scalability are more important than strict consistency, and when data is unstructured.

4. Performance Optimization & Scalability

Caching

  • What it is: A temporary, high-speed storage layer for frequently accessed data.
  • Why it Matters: Reduces database load and response latency. Cache must be smaller than the database for efficiency.
  • Strategies (Read/Write):
    • Read-Through Cache: Reads from cache, cache fetches from DB on miss.
    • Write-Through Cache: Writes go to cache first, then to DB (ensure data consistency).
    • Write-Around Cache: Writes go directly to DB, cache only populated on read (good for Twitter/X type workloads).
    • Write-Back Cache: Writes go to cache, asynchronously synced to DB (fast, but risk of data loss). Used in high-write scenarios like delivery status updates.
  • Eviction Policies: LRU (Least Recently Used), MRU (Most Recently Used), LFU (Least Frequently Used), FIFO, LIFO.

Load Balancers

  • Purpose: Distribute incoming traffic across multiple servers to prevent overload and increase availability.
  • Key Responsibilities:
    1. Choosing a Server (Algorithms):
      • Round Robin: Simple, equal distribution. Best for identical servers.
      • Geo-based: Routes users to the nearest server, reducing latency.
      • Least Connections: Sends requests to the server with the fewest active connections. Good for sticky sessions.
      • Least Time: Routes based on server response time. Ideal for real-time apps (trading, search).
      • IP Hash: Ensures a user always hits the same server. Used for session persistence but makes scaling difficult.
      • Weighted Round Robin: Servers with higher capacity get more requests.
    2. Health Checks:
      • Passive: Observes standard server responses to determine health.
      • Active: Sends dedicated health check requests.
      • Parameters: Interval, timeout, unhealthy threshold.

Replication

  • Purpose: Keep copies of data for fault tolerance, high availability, and improved read throughput.
  • Algorithms:
    • Single-Leader: One leader handles writes, then replicates to followers.
      • Async: Leader responds to user immediately, replicates later (faster, eventual consistency).
      • Sync: Leader waits for all followers to confirm (stronger consistency, slower). Async is generally preferred.
    • Multi-Leader: Multiple leaders accept writes, each replicates to its followers and to other leaders. Resolves conflicts via Last-Write-Wins, Replica ID, or user intervention.
    • Leaderless: Any node can accept reads/writes. Uses Quorum (e.g., wait for more than half of N nodes to respond) to confirm writes. Used in DynamoDB, Cassandra.

Partitioning (Sharding)

  • Why Partition?: When data is too large for a single node, or query performance degrades with indexes.
  • Goal: Data must be completely combined to form the full dataset (no data loss) and should be evenly distributed to avoid hotspots.
  • Methods:
    • Key Range: Divide by a range of keys (e.g., users 1-50000 on node 1, 50001-100000 on node 2). Can lead to hotspots if key distribution is not uniform.
    • Hash of Key: Use a hash function to distribute keys, more even distribution but still can cause hotspots for popular keys.
    • Partitioning by Secondary Index (Local): Each partition has its own secondary indexes. Requires scanning all partitions for a query.
    • Partitioning by Secondary Index (Global): A single global index knows which data is on which partition. Faster reads, but writes become more complex.

5. Consistency, Availability, and Fault Tolerance

CAP Theorem

CAP theorem states that a distributed data store can only provide two of the following three guarantees simultaneously:

  • C (Consistency): Every read returns the most recent write.
  • A (Availability): Every request receives a (non-error) response, without guarantee it contains the latest write.
  • P (Partition Tolerance): The system continues to operate even if network partitions occur between nodes.

Combinations:

  • CA: Only possible with a single-node system (no P).
  • CP: Consistency over Availability. System will stop serving to ensure data consistency during a partition.
  • AP: Availability over Consistency. System will serve potentially stale data to remain available.

Real-World Examples:

  • Instagram (AP): A slight delay in seeing a new post is acceptable; availability is paramount.
  • Banking (CP): A transaction must be consistent; it's okay to wait for confirmation.

Message Queues

  • Purpose: Decouple synchronous tasks from asynchronous ones. A producer puts a message into a queue, and a consumer processes it independently.
  • Model: Pub/Sub (Publisher/Subscriber).
  • Ordering:
    • FIFO (First-In, First-Out): Strict ordering, but a single failed message can block the queue.
    • Unordered: Processing continues even if one message fails.
    • Priority Queue: Higher priority messages are processed first.
  • Delivery:
    • Pull: Consumer requests messages from the queue when ready.
    • Push: Queue sends messages directly to the consumer.
  • DLQ (Dead Letter Queue): Holds messages that could not be processed successfully after a set number of retries, preventing them from blocking the main queue.
  • Use Cases: Email/SMS notifications, order processing, analytics logs. Avoid for real-time systems requiring immediate synchronous acknowledgments.

Fault Tolerance

Faults are categorized as:

  • Hardware: Random, unpredictable (disk failure, server crash). Mitigated by replication and redundancy.
  • Software: Deterministic, caused by bad code, configuration errors, or unhandled edge cases. Mitigated by thorough testing and logging.
  • Human: The most unpredictable. Mitigated by code reviews, good practices, and automation.

6. Monitoring & Observability

API Monitoring

  • Throughput: Requests per second. Set alerts when approaching limits.
  • Error Codes: Track 4xx and 5xx errors. Log details for root cause analysis.
  • Health Checks: Continuously monitor component status.
  • Latency: Use percentiles (P50, P90, P99) instead of averages to understand majority user experience. A large gap between P50 and P99 indicates high latency tail events.

Machine Monitoring

  • CPU Usage: Percentage of CPU in use.
  • Memory Usage: Percentage of RAM being consumed.
  • Disk I/O & Network: Input/output operations on disk and network bandwidth.

7. Practical Project: Designing a Video Streaming Platform

This final section demonstrates how to apply the learned concepts.

  1. Requirement: Stream a video (e.g., 50 GB, 4K, 60 FPS, 20 minutes) to 100,000 users.
  2. Solution:
    • Segmentation: Divide the video into 1200 segments (1 second each).
    • Resolutions: Create multiple quality levels (4K, 1080p, 720p, etc.) for each segment.
    • Adaptive Bitrate Streaming: A client-side algorithm automatically selects the highest possible quality segment based on current network bandwidth.
    • Architecture:
      • Source Video → Transformation Service (creates segments)
      • Segments → Priority Queue
      • Priority Queue → Worker 1 (to 1080p), Worker 2 (to 720p), etc.
      • Workers → Priority Queue 2
      • Priority Queue 2 → Distributed CDN (servers in India, US, etc.) → End User
  3. Maths:
    • Segment Size (4K): 50 GB / 1200 ≈ 42.6 MB
    • Segment Size (480p): 5 GB / 1200 ≈ 4.17 MB
    • Total for 100 users: ~8.7 GB. For 100,000 users, load balancing and CDN are required.
    • Iterate: This design is a starting point. Adding caching at the CDN or browser level, and potentially different cache strategies, would be the next iteration for improvement.

Final Advice for Interviews

  • Think out loud: Explain your reasoning and trade-offs.
  • Use components for the right reasons: Adding more components increases cost and complexity.
  • Start simple: Begin with a basic architecture and add complexity as requirements grow.

For a deeper exploration of these patterns, see the Comprehensive System Design Series: From Monolith to Microservices and Beyond.

Keep this summary

Save it to LunaNotes and it becomes a real note in your library — editable, searchable, and ready to turn into flashcards or a diagram. Free to start.

Save to LunaNotes

Or summarise for another video.

This summary and transcript were automatically generated using AI with the Free YouTube Transcript Summary Tool by LunaNotes.

Related summaries

Complete Architecture of Instagram Reels and YouTube Shorts Explained

Complete Architecture of Instagram Reels and YouTube Shorts Explained

Explore the end-to-end architecture of short video platforms like Instagram Reels and YouTube Shorts. Learn about upload workflows, video processing, personalized feed generation, engagement tracking, and scalable data handling designed to serve billions of views daily with low latency.

Comprehensive System Design Series: From Monolith to Microservices and Beyond

Comprehensive System Design Series: From Monolith to Microservices and Beyond

This extensive video series covers crucial system design concepts essential for software engineers, students, and developers preparing for FAANG interviews or building scalable startup systems. Dive deep into foundational topics like monolithic vs microservice architectures, API gateways, load balancers, networking protocols, caching strategies, distributed systems, rate limiting, SSL certificates, database choices, avoiding single points of failure, messaging queues, consistent hashing, and more with real-world examples and hands-on coding projects.

System Design Basics: Scalability, Cloud Hosting & API Explained

System Design Basics: Scalability, Cloud Hosting & API Explained

Learn the fundamentals of system design, including how to expose algorithms via APIs, the role of cloud hosting, and essential concepts like vertical and horizontal scaling. Discover the trade-offs between scalability, resilience, and consistency to design robust systems that meet real-world business requirements.

Scalable System Design Explained Using a Restaurant Analogy

Scalable System Design Explained Using a Restaurant Analogy

Explore how building a scalable, resilient system parallels running a growing pizza parlor. This guide covers vertical and horizontal scaling, fault tolerance, microservices, load balancing, and decoupling with real-world examples to simplify complex technical concepts.

HTTP Protocol Fundamentals: Statelessness, Methods, CORS, Caching, and Status Codes for Backend Developers

HTTP Protocol Fundamentals: Statelessness, Methods, CORS, Caching, and Status Codes for Backend Developers

This comprehensive guide explains core HTTP concepts every backend developer needs to know, covering stateless architecture, request/response headers, methods, status codes, CORS flow, caching strategies, content negotiation, and large data transfer. You'll learn why HTTP is stateless, how browsers handle cross-origin requests with preflight checks, and practical ways to optimize performance using caching and compression.

Found this summary useful?

Take it with you. One click puts it in your own LunaNotes library.

Save to LunaNotes

Start taking better notes today with LunaNotes