Chapter 2: Core System Design Concepts

This chapter covers the foundational concepts you must master for any system design interview.

Scalability vs. Performance

It is crucial to distinguish between these two often-confused terms.

[!TIP] You can have a highly performant system that doesn’t scale (e.g., a super-fast single server that crashes at 10k concurrent users). Conversely, you can have a scalable system that isn’t performant (e.g., a massive distributed cluster that returns every request in 2 seconds).

Vertical vs. Horizontal Scaling

Availability & Reliability

Key Metrics:

Designing for Failure

Assume everything will fail. Hard drives crash, networks partition, and data centers lose power. Your design must be resilient.

🧠 The CAP Theorem (In Practice)

In a distributed system, you can only guarantee 2 of the following 3 properties:

  1. Consistency ©: Every read receives the most recent write or an error.
  2. Availability (A): Every request receives a (non-error) response, without the guarantee that it contains the most recent write.
  3. Partition Tolerance (P): The system continues to operate despite an arbitrary number of messages being dropped or delayed by the network between nodes.

[!IMPORTANT] Partition Tolerance is not optional in real-world distributed systems. Networks fail. Therefore, you are essentially choosing between CP (Consistency + Partition Tolerance) and AP (Availability + Partition Tolerance).

ACID vs. BASE

🧱 Interview Q&A

Interviewer: “I have a legacy SQL database that is becoming slow. How do I scale it?”

Candidate: "I’d approach this in phases:

  1. Optimize First: Check for missing indexes, slow queries (N+1 problems), and unnecessary data fetching.
  2. Vertical Scaling (Scale Up): Increase RAM/CPU on the existing instance. This is the fastest, cheapest short-term fix.
  3. Read Replicas (Scale Out Reads): If the workload is read-heavy (usually 80/20 rule), add Read Replicas and point GET requests to them.
  4. Caching: Implement Redis/Memcached for frequently accessed data.
  5. Sharding (Scale Out Writes): If write throughput is the bottleneck, partition the data (e.g., by UserID) across multiple DB instances. This is complex and a last resort."

Interviewer: “Design a system for a real-time stock trading platform. Which CAP property do you sacrifice?”

Candidate: “For a stock trading core engine, Consistency is non-negotiable. If I buy a stock, I must own it immediately, and no one else can buy it. Therefore, I must choose a CP (Consistency + Partition Tolerance) system. This means if the network partitions or nodes fail, the system must reject trades (become unavailable) rather than allow a double-spend or incorrect balance. I would use a strongly consistent database (like PostgreSQL or a dedicated ledger) and avoid eventually consistent stores for the core ledger.”