System Design Fundamentals

Core concepts every engineer should internalize when designing systems at scale.

CAP Theorem

You can only guarantee two of three properties in a distributed system:

  • Consistency — Every read returns the most recent write
  • Availability — Every request receives a response
  • Partition Tolerance — System operates despite network failures

In practice, partitions are inevitable, so the real choice is between CP and AP.

Load Balancing Strategies

Strategy Use Case
Round Robin Equal capacity servers
Least Connections Varying request duration
Consistent Hashing Distributed caches
Weighted Mixed-capacity fleet

Key Principles

  1. Design for failure — Everything fails, plan for it
  2. Keep it stateless — State belongs in dedicated stores
  3. Cache aggressively — But know your invalidation strategy
  4. Monitor everything — You can’t fix what you can’t see

Premature optimization is the root of all evil, but premature architecture is the root of all waste.

Read vs Write Heavy

Understanding your access patterns drives every design decision:

  • Read-heavy: Add caching layers, read replicas, CDN
  • Write-heavy: Write-behind caching, event sourcing, append-only logs
  • Mixed: CQRS — separate read and write models