Flashcard Deck · 20 cards · Public

System Design - Distributed Systems & Scalability

Master core distributed systems and high-scalability architecture concepts with this high-yield flashcard deck covering CAP theorem, consistent hashing, caching strategies, load balancing, message queues, and rate limiting algorithms.

Cards in this deck

(20 cards)

Preview terms and definitions before starting your study session.

#1
Term
What is the CAP Theorem and why must distributed systems make trade-offs?
Definition
The CAP Theorem states that a distributed data store can simultaneously provide at most two of three guarantees:
  • Consistency (C): Every read receives the most recent write or an error.
  • Availability (A): Every non-failing node returns a non-error response (without guarantee of latest data).
  • Partition Tolerance (P): System continues operating despite network dropped/delayed messages.
Since network partitions () are inevitable in real-world systems, distributed databases must choose between Consistency () or Availability () during network disruptions.
#2
Term
What is the PACELC Theorem and how does it extend CAP?
Definition
PACELC extends CAP by describing system trade-offs during normal execution (when no network partition exists):
  • If Partition (P): Choose between Availability (A) or Consistency (C).
  • Else (E): Choose between Latency (L) or Consistency (C).
Example: DynamoDB is (favors availability and low latency), whereas MongoDB is (favors consistency under both partition and normal conditions).
#3
Term
Compare Horizontal Scaling (Scaling Out) vs. Vertical Scaling (Scaling Up).
Definition
  • Vertical Scaling (Scale Up): Adding hardware power (CPU, RAM) to a single machine. Simpler architecture, but limited by physical hardware limits and creates a single point of failure (SPOF).
  • Horizontal Scaling (Scale Out): Adding more machine nodes to a resource pool. Offers near-unlimited scalability and high fault tolerance, but introduces complexity with network latency, data partitioning, and consistency management.
#4
Term
How does Consistent Hashing work and why is it critical for distributed caching?
Definition
Consistent Hashing maps both keys and nodes to a logical ring using a uniform hash function (e.g., hash(key) % 2^32). A key is assigned to the first node encountered moving clockwise.
Key Advantage: When adding or removing a node, only keys need to be remapped on average (where is total keys and is total nodes). Virtual nodes are used to distribute keys uniformly across physical hardware and prevent hotspots.
#5
Term
What is Database Sharding and what main challenges does it introduce?
Definition
Sharding is horizontally partitioning data across multiple database instances using a Shard Key (e.g., user_id).
Pros: Scalable write throughput, increased memory/disk capacity.
Challenges:
  • Cross-shard JOINs: Extremely slow and complex.
  • Hotspotting: Poor shard key choice leads to unbalanced traffic on a single shard.
  • Resharding Complexity: Re-balancing data as storage needs grow is operationally difficult.
#6
Term
What causes Replication Lag and how can read-after-write inconsistencies be prevented?
Definition
Replication lag occurs in asynchronous primary-replica database setups when write updates delay reaching replica nodes, leading to stale reads.
Mitigation Strategies:
  • Read critical user writes directly from the Primary Node (e.g., user reading their own updated profile).
  • Enforce Strong Quorum Consistency ().
  • Route reads to replicas only after a minimum timestamp/log offset has been reached.
#7
Term
Explain the Cache-Aside (Lazy Loading) pattern workflow.
Definition
1. Application checks the cache for requested data.
2. Cache Hit: Data is returned immediately to the client.
3. Cache Miss: Application queries the primary database, populates the cache with the fetched result, and returns data to client.
Pros: Cache only contains requested data; cache node failures don't crash the system (falls back to DB).
Cons: Initial cache miss penalty; risk of stale cache if DB updates bypass invalidation.
#8
Term
Compare Write-Through and Write-Back (Write-Behind) caching strategies.
Definition
  • Write-Through: Application writes to cache, and the cache synchronously writes to the DB before returning success. Low write performance, but ensures zero stale cache reads.
  • Write-Back: Application writes to cache, which acknowledges immediately. The cache asynchronously flushes batched writes to DB. Provides ultra-low write latency, but risks data loss if cache nodes crash before flushing.
Showing 8 of 20 cards in this deck.
Study All Now