Sign in

System design fundamentals, from single servers to distributed architectures

Understand the definition, purpose, and foundational patterns of system design to plan, build, and scale reliable software architectures.

MonksBit Desk

November 18, 2026 · 9 min read · 55 views

Read

System design is the process of defining the architecture, components, modules, interfaces, and data flow of a software system to satisfy specified technical and business requirements. It bridges the gap between raw business goals and concrete software implementations by planning how data moves, where compute executes, and how resources scale.

You will need. Basic knowledge of client-server networking (HTTP requests and responses) · Familiarity with standard databases and basic data persistence · Understanding of core programming concepts like functions and classes

How well do you know this already?

The full lesson

Level 1 · Beginner: Understanding the core purpose and anatomy of a simple system

At its core, system design answers two basic questions: how should software be structured to solve a problem today, and how will it continue to function reliably as demands increase tomorrow? Every system starts with requirements that fall into two categories: functional requirements (what the application must do, such as authenticating users or posting messages) and non-functional requirements (how the application performs, such as handling 10,000 requests per second with under 100 milliseconds latency).

The simplest software system consists of a single tier where a client sends requests over the network directly to a server, and that server processes logic and writes to an attached database. While this setup works for small prototypes, it contains single points of failure and strict resource limits dictated by the physical machine running the code.

Consider a basic task management service where a user fetches and updates task records. To walk through this by hand: the client initiates an HTTP GET request to /tasks; the single server receives the network socket connection, parses the request, executes a local database query on the same machine, serializes the rows into JSON, and transmits the response back to the client. If fifty thousand users do this at the same instant, the single machine runs out of memory or CPU cycles and crashes.

System design provides the principles needed to avoid these failures by modularizing responsibilities, introducing layers of separation between compute and storage, and preparing systems to scale horizontally.

A minimal monolithic server demonstrating single-tier architecture without separation of concerns

import jsonfrom http.server import BaseHTTPRequestHandler, HTTPServer# In-memory storage acting as both application state and databaseDATA_STORE = {    1: {"id": 1, "title": "Buy groceries", "done": False},    2: {"id": 2, "title": "Read documentation", "done": True}}class SimpleServer(BaseHTTPRequestHandler):    def do_GET(self):        if self.path == "/tasks":            self.send_response(200)            self.send_header("Content-Type", "application/json")            self.end_headers()            response_data = json.dumps(list(DATA_STORE.values()))            self.wfile.write(response_data.encode("utf-8"))        else:            self.send_response(404)            self.end_headers()def run(port=8080):    server = HTTPServer(("", port), SimpleServer)    print(f"Server running on port {port}...")    server.serve_forever()if __name__ == "__main__":    run()

Key takeaways

  • System design formalizes how modules, data stores, and interfaces interact to deliver software services.
  • Requirements split into functional goals (features) and non-functional goals (scalability, availability, latency).
  • Monolithic single-tier systems are simple to build but fail under increased traffic due to shared resource limits.

Level 2 · Intermediate: Decoupling components, managing state, and scaling horizontally

When a single machine runs out of resources, there are two scaling paradigms: vertical scaling and horizontal scaling. Vertical scaling means adding more compute capacity—such as faster CPUs or more RAM—to an existing machine. This has a physical ceiling and does not eliminate the single point of failure. Horizontal scaling means adding more independent machines to work in parallel, which requires stateless server nodes and external coordination.

To enable horizontal scaling, the application tier must become stateless. A stateless server does not retain client session data or state across requests in its local memory; any incoming request can be routed to any identical worker machine. Shared state is delegated to persistent distributed storage or an external cache.

A core component in horizontally scaled systems is the load balancer. The load balancer receives incoming traffic from clients and distributes requests across a pool of healthy backend application servers using strategies such as Round Robin, Least Connections, or consistent hashing.

Testing intermediate systems requires verifying that failure of a single worker node does not disrupt overall availability, and ensuring that concurrent writes to decoupled storage layers do not cause data corruption or race conditions.

A stateless worker service communicating with a shared storage layer and health check endpoint

import jsonfrom http.server import BaseHTTPRequestHandler, HTTPServerfrom typing import Dict, Any# Simulated external shared state (e.g., Redis or SQL database)SHARED_DATABASE: Dict[int, Dict[str, Any]] = {}class StatelessTaskWorker(BaseHTTPRequestHandler):    def do_GET(self):        if self.path == "/health":            # Load balancers query health endpoints to verify node availability            self.send_response(200)            self.send_header("Content-Type", "application/json")            self.end_headers()            self.wfile.write(json.dumps({"status": "healthy"}).encode("utf-8"))        elif self.path == "/tasks":            self.send_response(200)            self.send_header("Content-Type", "application/json")            self.end_headers()            payload = json.dumps(list(SHARED_DATABASE.values()))            self.wfile.write(payload.encode("utf-8"))        else:            self.send_response(404)            self.end_headers()    def do_POST(self):        if self.path == "/tasks":            content_length = int(self.headers.get("Content-Length", 0))            body = self.rfile.read(content_length)            try:                data = json.loads(body.decode("utf-8"))                new_id = len(SHARED_DATABASE) + 1                record = {"id": new_id, "title": data.get("title", ""), "done": False}                SHARED_DATABASE[new_id] = record                                self.send_response(201)                self.send_header("Content-Type", "application/json")                self.end_headers()                self.wfile.write(json.dumps(record).encode("utf-8"))            except (json.JSONDecodeError, KeyError):                self.send_response(400)                self.end_headers()        else:            self.send_response(404)            self.end_headers()

Key takeaways

  • Vertical scaling adds power to one machine; horizontal scaling distributes workload across many machines.
  • Statelessness in the compute tier allows arbitrary routing of client requests across pool instances.
  • Load balancers act as reverse proxies, distributing load and isolating unhealthy application nodes.

Level 3 · Advanced: Distributed trade-offs, consistency models, and resiliency mechanisms

In distributed environments, independent nodes must coordinate over networks that are inherently unreliable. System design at this stage focuses on formal constraints, such as the CAP theorem, which proves that a distributed data store can guarantee at most two out of three properties simultaneously: Consistency (every read receives the most recent write or an error), Availability (every non-failing node returns a response), and Partition Tolerance (the system continues to operate despite arbitrary dropped or delayed network messages). Since physical network partitions are unavoidable in distributed hardware, engineers must choose between Consistency and Availability during network failures.

When optimizing for high throughput and fault tolerance, systems introduce asynchronous processing via message brokers (such as Kafka or RabbitMQ) and in-memory caching tiers (such as Redis). Caching reduces read pressure on primary databases by storing frequently accessed data with sub-millisecond retrieval times. However, caches introduce cache invalidation complexity and cache stampede vulnerabilities.

Another critical advanced design concept is fault isolation. In microservice architectures, cascading failures occur when one slow downstream dependency causes thread exhaustion across upstream callers. Resiliency patterns like circuit breakers, rate limiters, and bulkheads prevent isolated degradations from bringing down the entire ecosystem.

Designing complex systems involves balancing trade-offs rather than searching for perfect solutions: strong consistency increases latency, replication improves availability but introduces replication lag, and fine-grained microservices offer team independence at the cost of operational overhead and distributed tracing complexity.

A cache-aside implementation with fallback database retrieval and TTL expiration handling

import timefrom typing import Optional, Dict, Anyclass CacheAsideService:    def __init__(self):        # Simulated persistent database        self._db: Dict[str, str] = {"user:101": "Alice", "user:102": "Bob"}        # In-memory cache with expiry: key -> (value, expire_at_timestamp)        self._cache: Dict[str, tuple[str, float]] = {}    def get_user(self, user_id: str) -> Optional[str]:        cache_key = f"user:{user_id}"        now = time.time()                # 1. Read from cache first        if cache_key in self._cache:            val, expires_at = self._cache[cache_key]            if now < expires_at:                return val            # Clean up expired entry            del self._cache[cache_key]                    # 2. On cache miss, read from primary database        val = self._db.get(cache_key)        if val is not None:            # 3. Populate cache with a Time-To-Live (e.g., 60 seconds)            self._cache[cache_key] = (val, now + 60.0)                    return val    def update_user(self, user_id: str, new_name: str) -> None:        cache_key = f"user:{user_id}"        # Write to primary database        self._db[cache_key] = new_name        # Invalidate cache entry to avoid serving stale data        if cache_key in self._cache:            del self._cache[cache_key]

Key takeaways

  • The CAP theorem dictates that distributed systems must choose between Consistency and Availability during network partitions.
  • Caching tiers significantly reduce database read amplification but introduce consistency and invalidation challenges.
  • Resiliency mechanisms such as circuit breakers and rate limiters protect systems against catastrophic cascading failures.

Complexity

  • Time: O(1) to O(log N) for cached routing and indexed reads; O(N) worst-case on unindexed queries
  • Space: O(N) to O(N * R) total storage, where N is data volume and R is replication factor across cluster nodes

Compute latency depends on component topology: memory caches resolve in O(1) time, while clustered primary databases use B-tree indices running in O(log N) time. Spatial footprint scales linearly with distinct records multiplied by replication factors used for durability and high availability.

Common mistakes

  • Over-engineering architectures upfront by introducing microservices and distributed queues before traffic levels or domain boundaries justify them.
  • Neglecting single points of failure by routing redundant application instances through an un-replicated database or un-clustered proxy.
  • Failing to implement backpressure or rate limiting, leading to cascading resource starvation across downstream internal services during traffic surges.
  • Confusing horizontal scaling with fault tolerance without accounting for data synchronization, leading to race conditions and stale reads.

Practice problems

  1. Design a basic URL shortener (easy). Hint: Calculate the read-to-write ratio, estimate storage capacity for five years, and define a unique hash-to-ID mapping scheme.
  2. Design a distributed rate limiter (medium). Hint: Select an appropriate algorithm such as Token Bucket or Sliding Window Counter, and consider how to maintain atomicity across worker nodes using shared cache primitives.
  3. Design a globally available distributed key-value store (hard). Hint: Analyze partition tolerance, choose a consensus algorithm (such as Raft or Paxos) or conflict resolution strategy (like vector clocks), and establish replication policies.

Summary

System design is the structured discipline of organizing compute, storage, and networking layers to deliver performant and reliable software. By transitioning from single-node systems to horizontally scalable, decoupled architectures and navigating distributed systems trade-offs, engineers can satisfy growing capacity needs without sacrificing system availability or correctness.

Was this helpful?

Comments (0)

Sign in or create an account to join the conversation.

  • No comments yet. Be the first!