System Design Fundamentals

Core Building Blocks

4 min read

Every large-scale system is built from the same fundamental components. Knowing these building blocks and when to use each one is essential for system design interviews.

Load Balancers

Distribute traffic across multiple servers to prevent any single server from becoming a bottleneck.

TypeLayerHow It WorksUse Case
L4 (Transport)TCP/UDPRoutes by IP and portHigh throughput, simple routing
L7 (Application)HTTPRoutes by URL, headers, cookiesContent-based routing, SSL termination

Algorithms: Round Robin, Least Connections, IP Hash, Weighted Round Robin

Caching

Store frequently accessed data in fast storage (memory) to reduce database load and latency.

Caching Strategies:

StrategyHow It WorksBest For
Cache-AsideApp checks cache first, loads from DB on missGeneral purpose, read-heavy
Write-ThroughWrite to cache and DB simultaneouslyData consistency
Write-BackWrite to cache, async write to DBWrite-heavy, risk of data loss
Read-ThroughCache loads from DB transparentlySimplicity
Cache-Aside Pattern:
1. App checks Redis → Hit? Return data
2. Miss? Query database
3. Store result in Redis with TTL
4. Return data to client

Popular Caches: Redis (most common in interviews), Memcached

Interview Tip: Always mention cache invalidation as a challenge. It's one of the hardest problems in distributed systems.

Databases

SQL vs NoSQL

FeatureSQL (PostgreSQL, MySQL)NoSQL (MongoDB, DynamoDB)
SchemaFixed, structuredFlexible, schema-less
ScalingVertical (scale up)Horizontal (scale out)
JoinsNative supportLimited or manual
TransactionsACID compliantEventual consistency (usually)
Best forComplex queries, relationshipsHigh throughput, flexible data

Scaling Databases

Replication: Copy data to multiple servers

  • Master-slave: one writer, many readers
  • Master-master: multiple writers (complex conflict resolution)

Sharding: Split data across multiple databases

  • Range-based: user IDs 1-1M on shard 1, 1M-2M on shard 2
  • Hash-based: hash(user_id) % num_shards
  • Consistent hashing: minimizes redistribution when adding/removing shards

Message Queues

Decouple services by communicating through a queue instead of direct calls.

SystemStrengthsUse Case
KafkaHigh throughput, log-based, replayEvent streaming, logs
RabbitMQFlexible routing, acknowledgmentsTask queues, RPC
SQSManaged, simple, reliableAWS-native workflows

When to Use: Asynchronous processing, peak load handling, service decoupling, event-driven architecture.

CDN (Content Delivery Network)

Serve static content (images, CSS, JS) from servers geographically close to users.

  • Push CDN: You upload content to CDN (good for static sites)
  • Pull CDN: CDN fetches from origin on first request, then caches (good for dynamic content)

API Design

StyleFormatBest For
RESTHTTP + JSONGeneral CRUD, simple APIs
GraphQLSingle endpoint, query languageComplex data needs, mobile apps
gRPCProtocol Buffers, HTTP/2Microservice communication, low latency

Building Blocks Cheat Sheet

NeedSolution
Distribute trafficLoad Balancer
Reduce latencyCache (Redis)
Store structured dataSQL Database
Store unstructured dataNoSQL Database
Async processingMessage Queue
Serve static content globallyCDN
Search textElasticsearch
Unique IDs at scaleSnowflake ID / UUID

Next, let's apply these building blocks to classic system design problems. :::

Quiz

Module 4 Quiz: System Design Fundamentals

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.