Tag: Architecture

  • The System Design Staircase: What to Learn, In What Order

    System design feels overwhelming for one reason: people try to learn it from the top step. Consensus algorithms before load balancers. Distributed transactions before databases. The knowledge is a staircase, not a pile — each step assumes the one below it, and climbing in order turns a scary subject into a sequence of small, obvious ones.

    The system design staircase: basic, intermediate, advanced

    Step 1: Basic — how one system serves users

    Load Balancer. One front door that distributes incoming traffic across servers, so no single machine is the ceiling. (NGINX, AWS ELB.)

    API Gateway. The single entry point for client requests: routing, authentication, and rate limiting handled in one place instead of inside every service. (Kong, AWS API Gateway.)

    Content Delivery Network (CDN). Static assets copied to servers near the user, so a page in Texas does not wait on a disk in Virginia. (Cloudflare, Akamai.)

    Database Fundamentals. Where structured data lives — SQL (MySQL, PostgreSQL) and NoSQL (MongoDB) — and how it is queried. Everything above this step exists to protect or feed the database.

    Master these four and you can design a system that serves real users. Most internal tools never need more.

    Step 2: Intermediate — how a system grows

    Caching. Keep hot data in memory so the database stops answering the same question a million times a day. (Redis, Memcached.)

    Rate Limiting. Cap requests per user or app, so growth — or abuse — cannot take the system down with enthusiasm.

    Database Sharding. Split a dataset across machines, by user ID or region, when one database honestly cannot hold or serve it all.

    Replication. Copy data across servers for high availability and disaster recovery — the master–slave setups that keep reads fast and data alive.

    This step is where most production systems live. If Step 1 is “working,” Step 2 is “working at ten times the traffic.”

    Step 3: Advanced — how systems agree, survive, and stay honest

    CAP Theorem. During a network partition, choose consistency or availability. The trade-off that defines distributed systems.

    Eventual Consistency. The relaxation of CAP: all nodes will agree eventually, just not instantly. (DynamoDB and most planet-scale systems.)

    Distributed Transactions. Keeping an operation atomic across services and databases — coordination protocols like 2PC, and patterns like SAGA when 2PC does not fit.

    Consensus Algorithms. How distributed nodes agree on anything — leader, value, state — when some of them are lying dead. (Paxos, Raft; inside etcd and ZooKeeper.)

    Message Queues. Decoupling services with asynchronous communication, so a slow consumer never blocks a fast producer. (RabbitMQ, Kafka.)

    Service Discovery. In environments where services appear, disappear, and move, something must keep the phone book. (Consul, Eureka.)

    System Observability. Monitoring, logging, and tracing — knowing the system’s health from the outside before your users tell you from the inside. (Prometheus, Grafana, Jaeger.)

    The bottom line

    Basic serves users, intermediate survives growth, advanced survives failure and disagreement. Learn — and interview, and design — in that order, and you will never freeze in a design review again.

    Climbing the staircase? The free toolkits collect the reference posters for each step.

  • Monolith vs Microservices: The Honest Comparison

    This is the most argued decision in software architecture, and most teams make it for the wrong reason — fashion, a conference talk, or a resume. The honest version is simpler: a monolith is one application that deploys together; microservices are many small applications that deploy independently. Everything else follows from that.

    Monolith request flow

    Microservices request flow

    The two shapes

    Monolith. All modules — auth, orders, payments, notifications — live in one codebase, deploy as one unit, and usually share one database. A request travels inside a single process: function calls, not network calls.

    Microservices. The application is split by business capability. Each service owns one job, its own codebase, its own deployment pipeline, and its own database. Services talk through APIs and events.

    Side by side

    Feature Monolith Microservices
    Codebase One One per service
    Deployment Everything together Each service independently
    Scaling Scale the whole app Scale only the hot service
    Coupling Tight — modules touch directly Loose — contracts between services
    Data Usually one shared database Decentralized, per service
    Fault isolation One failure can take the app down Failures can be contained
    Development speed Fast early Faster for many large teams
    Testing Simpler end-to-end Complex integration testing
    Operations Easy to run Demands automation + observability
    Best for Small/medium apps, early products Large, complex platforms

    When each one wins

    Choose a monolith when the team is small, the domain is still being discovered, and speed of change matters more than independent scale. Most products should start here: you can refactor a working monolith; you cannot refactor a distributed system you did not need into existence.

    Choose microservices when the pain is real and named: teams stepping on each other’s releases, one module needing 50× the scale of the rest, or independent deployment becoming a business requirement. Microservices trade code complexity for organizational scalability — that is the actual product you are buying.

    The analogy that settles it

    A monolith is a department store: everything under one roof, one management, easy to run — and a fire anywhere can close the whole store. Microservices are a shopping complex: specialized stores, each opening, closing, and expanding on its own — and now somebody has to run the mall: security, utilities, parking, signs. Neither is “better.” They are answers to different sizes of problem.

    The bottom line

    Start simple. Earn the complexity. Move to microservices when scale, team autonomy, and independent deployment become real needs with names and numbers — not when a blog post says monoliths are dead. The best architecture is the one your team can actually operate at 2 AM.

    More architecture decisions, made the same honest way: the free toolkits and posters collect them.

  • 20 System Design Frameworks, Grouped So You Actually Remember Them

    Twenty frameworks is a lot to memorize — until you notice they are answers to only four questions. How consistent must the data be? How much traffic is coming? What happens when something breaks? And how should work flow between services?

    Sort the twenty into those four families and the list stops being a list. It becomes a checklist you can run in any design review.

    The 20 system design frameworks in 4 families

    Family 1: Consistency & Data — “What is the truth, and where does it live?”

    CAP Theorem. When a network partition splits your system, you must choose: stay consistent (every read sees the latest write) or stay available (every request gets an answer, possibly stale). You cannot have both during a partition. This is the first fork in every distributed design.

    PACELC Model. CAP only speaks during failures. PACELC adds the everyday case: else (no partition), you still trade Latency against Consistency. It is CAP for real life, because most days nothing is broken — and you are still making the trade.

    Database Sharding. Split one large dataset across many databases — by user ID, by region, by any key that spreads the load evenly. Reach for it when a single database genuinely cannot carry the workload, not before.

    Replication. Copy data across nodes so the system survives losing one. Leader–follower when one writer is enough; multi-leader when writes must happen in more than one place. Replication buys reliability and read scale; it charges you in consistency headaches.

    Consistent Hashing. The ring that decides which node owns which key — designed so that adding or removing a node moves only a small slice of the data, not everything. It is why sharded systems can scale without a weekend of rebalancing.

    Family 2: Traffic & Scale — “Too many requests, not enough server”

    Load Balancing. Spread incoming traffic across servers: round-robin for simple cases, least-connections when requests vary, hashing when a user must land on the same node. The goal is boring — no server drowning while its neighbor idles.

    Caching Strategies. Keep frequently read data close and fast. Cache-aside (the app checks the cache, fills it on a miss), write-through, write-back — the variations are about when the cache and the database agree.

    Write-Through Caching. The specific pattern worth naming on its own: every write updates the cache and the database together, so the cache is never stale. You pay a little write latency to buy reads you can trust.

    Rate Limiting. Cap how many requests a client may make in a window. It protects availability, enforces fairness between customers, and turns abuse into a polite 429 instead of an outage.

    Back-of-the-Envelope Estimation. Rough capacity math with stated assumptions: users × requests × size = storage, bandwidth, servers. Five minutes of arithmetic that kills unbuildable designs before they consume a quarter.

    Family 3: Staying Alive — “Something will fail; then what?”

    Circuit Breaker. When a downstream service keeps failing, stop calling it for a while — fail fast, let it recover, test it with a trickle before reopening the floodgates. Named after the electrical part because it does the same job: it keeps a fault from burning down the house.

    Retry Patterns. Failed requests often succeed on a second attempt — but retry with exponential backoff and jitter, or a thousand clients retrying in lockstep become the outage.

    Bulkhead Pattern. Partition your own resources the way a ship’s hull is partitioned: separate thread pools per dependency, so one slow service floods only its own compartment instead of sinking the whole application.

    Leader Election. In a cluster, exactly one node coordinates. Leader election picks that node dynamically and replaces it when it dies — the quiet mechanism behind half the systems in this list.

    Gossip Protocol. Nodes spread state by chatting with random peers, the way news spreads through an office. No central coordinator, no bottleneck — large clusters stay informed eventually, which is usually enough.

    Family 4: Flow & Coordination — “How does work move and stay correct?”

    Event-Driven Design. Services react to events instead of calling each other directly. The producer does not know or care who consumes — which is what decoupling actually means.

    CQRS. Separate the write model from the read model (Command Query Responsibility Segregation). When reads and writes have wildly different shapes and volumes, optimizing one shared model serves neither.

    Saga Pattern. A distributed transaction built from local transactions plus compensating actions. Book the flight, charge the card, reserve the hotel — and if step three fails, undo steps one and two. No two-phase commit across services; consistency by choreography instead.

    Idempotency. Design operations so running them twice has the same effect as running them once. It is what makes retries, duplicate deliveries, and nervous users with double-clicks safe — the foundation every payment API stands on.

    Event Sourcing. Store the events (what happened) instead of the final state. Current state is rebuilt by replaying history — which gives you a complete audit trail and time travel as side effects. Powerful, and heavier than most systems need.

    The bottom line

    Nobody recalls twenty frameworks under pressure. They recall four questions — consistency, traffic, failure, flow — and pull the right tool from the right family. Learn the families and the twenty names will attach themselves.

    Want the whole set as a printable reference? The free toolkits at aideeva.com/free-toolkits/ include the AI Engineering Iceberg Poster and architecture cheat sheets built the same way — grouped to be remembered.