Sign in

How to approach a system design problem, from scope to architecture?

Master a structured framework to clarify requirements, estimate scale, design high-level architectures, and resolve deep distributed bottlenecks.

MonksBit Desk

November 25, 2026 · 8 min read · 47 views

Read

A system design approach is an iterative, structured methodology for planning the architecture, modules, and interfaces of an end-to-end software system. It transforms ambiguous business requirements into a scalable, resilient, and verifiable distributed system blueprint.

You will need. Basic knowledge of client-server networking (HTTP, TCP) · Familiarity with relational and non-relational database concepts · Understanding of core data structures like hash tables and queues

How well do you know this already?

The full lesson

Level 1 · Beginner: The foundational four-step system design framework

Approaching a system design problem requires resisting the urge to jump directly into drawing boxes and selecting databases. Unstructured brainstorming leads to missing critical functional needs and over-engineering components. A disciplined approach uses a standardized four-phase sequence: clarify functional and non-functional requirements, formulate back-of-the-envelope capacity estimations, define data models and application interfaces, and sketch the end-to-end high-level component diagram.

Consider a small, practical prompt: design a URL shortener service like TinyURL. Step one clarifies requirements: users submit a long URL and receive a unique short URL; visiting the short URL redirects them via an HTTP 302 or 301 status code. Non-functional goals establish that redirects must occur in under 20 milliseconds, with high availability taking priority over strong consistency.

Step two estimates scale by hand: assume 100 million new URLs created monthly with a 10-to-1 read-to-write ratio. This yields roughly 40 write requests per second and 400 read requests per second. At 500 bytes per URL mapping, storing 100 million records consumes approximately 50 gigabytes per month, which easily fits within conventional relational or key-value storage nodes without requiring initial multi-region sharding.

The following implementation demonstrates a minimal in-memory URL shortening service. It encapsulates core functional mechanics: base62 ID generation, clean lookup abstractions, and persistent mapping logic.

Minimal in-memory URL shortener demonstrating the core functional flow

class URLShortener:    BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"    def __init__(self):        self.url_map = {}        self.id_counter = 1000000    def _encode(self, num: int) -> str:        chars = []        while num > 0:            chars.append(self.BASE62[num % 62])            num //= 62        return "".join(reversed(chars))    def shorten(self, original_url: str) -> str:        short_key = self._encode(self.id_counter)        self.url_map[short_key] = original_url        self.id_counter += 1        return f"https://short.est/{short_key}"    def resolve(self, short_key: str) -> str | None:        return self.url_map.get(short_key)# Example usageservice = URLShortener()short = service.shorten("https://monksbit.com/algorithms/distributed-consensus")assert service.resolve(short.split("/")[-1]) == "https://monksbit.com/algorithms/distributed-consensus"

Key takeaways

  • Always clarify functional expectations and operational constraints before proposing technical components.
  • Use back-of-the-envelope calculations to ground system scale in realistic request and storage figures.
  • Map out API endpoints and core data representations before designing distributed infrastructure.

Level 2 · Intermediate: Handling scale, caching layers, and failover boundaries

Once basic requirements and components are mapped, the intermediate phase focuses on horizontal scaling, persistence strategies, and mitigating latency hotspots. Real-world services face high concurrency and uneven access patterns, where 20 percent of records often generate 80 percent of traffic. To shield persistent stores from read bottlenecks, a caching layer using a least-recently-used eviction policy is introduced between application instances and storage.

Data consistency boundaries must be declared explicitly. For a read-heavy system, we leverage read-replicas or partitioned key-value stores. Write requests pass through the primary node or a partitioned cluster using consistent hashing to assign keys uniformly across nodes without catastrophic re-allocation during topology changes.

The following production-style component models an application-tier caching router. It includes cache invalidation, a fallback to primary database persistence, and standard key generation handling collisions and concurrent reads.

Caching layer integration with read-through pattern and fallback persistence

from collections import OrderedDictimport threadingclass LRUCache:    def __init__(self, capacity: int):        self.capacity = capacity        self.cache = OrderedDict()        self.lock = threading.Lock()    def get(self, key: str) -> str | None:        with self.lock:            if key not in self.cache:                return None            self.cache.move_to_end(key)            return self.cache[key]    def put(self, key: str, value: str) -> None:        with self.lock:            if key in self.cache:                self.cache.move_to_end(key)            self.cache[key] = value            if len(self.cache) > self.capacity:                self.cache.popitem(last=False)class ScaledURLService:    def __init__(self, db_store: dict, cache_capacity: int = 1000):        self.db = db_store        self.cache = LRUCache(capacity=cache_capacity)    def get_url(self, token: str) -> str | None:        # Check cache first (Read-Through pattern)        cached_target = self.cache.get(token)        if cached_target is not None:            return cached_target        # Cache miss: query persistent store        target = self.db.get(token)        if target:            self.cache.put(token, target)        return target

Key takeaways

  • Introduce read-through caching and connection pooling to mitigate database throughput bottlenecks.
  • Structure persistence around access patterns using consistent hashing or partitioned primary-replica topologies.
  • Account for cache invalidation, stampedes, and eviction policies during high read traffic.

Level 3 · Advanced: Distributed bottlenecks, consensus, and fault isolation

In enterprise-scale architectures, single points of failure and cross-network latency dictate design choices. Designing at this level requires applying distributed patterns such as asynchronous messaging, rate limiting, distributed lock management, and circuit breakers. Systems operating across geographical zones must navigate the CAP theorem: in the presence of a network partition, you must deliberately choose between availability and strong consistency.

For write-heavy systems, synchronous writing to single databases creates unbearable lock contention. We decouple ingest paths using event streams like Apache Kafka, processing workloads asynchronously through worker pools. For operations requiring bounded rate or quota limits, token bucket or sliding-window rate limiters are deployed at API gateways to protect downstream components.

The code below implements a thread-safe distributed rate-limiting abstraction based on the Token Bucket algorithm, a standard pattern for protecting backend microservices from denial-of-service degradation.

Token bucket rate limiter to protect downstream components from overload

import timeimport threadingclass TokenBucketLimiter:    def __init__(self, capacity: float, refill_rate_per_sec: float):        self.capacity = float(capacity)        self.tokens = float(capacity)        self.refill_rate = float(refill_rate_per_sec)        self.last_update = time.monotonic()        self.lock = threading.Lock()    def allow_request(self, tokens_needed: float = 1.0) -> bool:        with self.lock:            now = time.monotonic()            elapsed = now - self.last_update            self.last_update = now            # Refill tokens proportional to elapsed time            self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate)            if self.tokens >= tokens_needed:                self.tokens -= tokens_needed                return True            return False

Key takeaways

  • Use asynchronous message brokers to absorb bursty write workloads and decouple processing stages.
  • Implement resilience patterns including circuit breakers, retry backoffs, and rate limiters at ingress boundaries.
  • Evaluate trade-offs between consistency, availability, and network latency explicitly across data stores.

Complexity

  • Time: O(1) average lookup and insertion time across cached and hash-partitioned services; worst-case O(log N) or O(N) during distributed partition rebalances.
  • Space: O(N) total distributed storage space where N is the total number of historical entities stored across persistent disk and RAM layers.

Key lookups in a consistent hash ring or cached distributed table require constant time on average. Total memory and disk scale linearly with the volume of generated entries, retention duration, and replica count.

Common mistakes

  • Jumping immediately into choosing specific technologies (e.g. Cassandra, Kafka) before clarifying scale and access patterns.
  • Ignoring non-functional requirements such as availability, latency targets, and data consistency models.
  • Over-engineering a distributed cluster for small workloads that a single relational instance could comfortably serve.
  • Failing to account for single points of failure across infrastructure like load balancers, primary databases, or single-point ID generators.
  • Neglecting back-of-the-envelope calculations, leading to unverified assumptions regarding network bandwidth and storage limits.

Practice problems

  1. Design a Distributed Key-Value Cache (easy). Hint: Focus on eviction policies, hash-based key distribution, and read-through versus write-through mechanisms.
  2. Design a Globally Scalable Rate Limiter (medium). Hint: Analyze concurrency across multiple API gateway nodes and assess the latency trade-offs of centralized Redis stores versus local in-memory token buckets.
  3. Design an Asynchronous Video Transcoding Pipeline (hard). Hint: Break down chunked video upload, message queues for worker distribution, progress tracking, and idempotent task retries.

Summary

Approaching a system design problem is a structured conversation rather than an exercise in memorizing diagrams. By systematically establishing functional requirements, backing assertions with capacity math, drafting clean interfaces, and progressively layering caching, partitioning, and resilience patterns, you can design distributed systems capable of scaling reliably under extreme real-world workloads.

Finish the Prove step above to complete this lesson.

Was this helpful?

Comments (0)

Sign in or create an account to join the conversation.

  • No comments yet. Be the first!