Core Building Blocks: Load Balancers, Caches, Queues, Databases and CDNs
Almost every system design answer is assembled from the same handful of parts. This lesson is the last step of the crash course, for engineers who know what each part is called but not yet when to reach for it. For each building block you will learn what it does, the signal in a problem that tells you to add it, the trade-off it brings, and the follow-up question the interviewer asks next. Then you will put them together into a high-level design for a URL shortener and justify every box.
How the high-level design is scored
After requirements and estimation, the interviewer expects a high-level design within about the first 15 to 20 minutes: a diagram and a walkthrough of the main request paths. They score whether the parts fit the requirements, whether each one is justified, and whether you see what it costs. The follow-up questions below are what they use to separate a memorized diagram from real understanding, so prepare an answer for each.
Load balancer
What it does. Spreads incoming requests across a pool of servers, checks their health, and removes failed servers from rotation. Layer 4 balancers route by IP and port and are very fast; layer 7 balancers understand HTTP and can route by path or header, terminate TLS and retry failed requests.
The signal. More traffic than one server can handle, or any availability requirement at all, because one server is one point of failure.
The trade-off. It only works cleanly with stateless servers. It is also a component that can fail, so in production it runs as a redundant pair or a managed service.
The follow-up. "How does the load balancer know a server is unhealthy, and how fast does it react?" Talk about health check endpoints, intervals and the window in which some requests still fail. The load balancing deep dive goes further.
Application servers, kept stateless
What they do. Run your business logic. Kept stateless, any server can take any request, so you scale by adding servers and survive by losing them.
The signal. Always present; the question is only whether they hold state. If your design keeps sessions, uploads in progress or open connections on a specific server, say so and say how you handle that server dying.
The follow-up. "Where does session state live?" A shared cache, the database, or a signed token held by the client, each with a sentence on why.
Database
What it does. Stores the source of truth. A relational database gives you transactions, joins and constraints. A key-value or wide-column store gives you simple access by key and easy horizontal scaling. A document store keeps nested records together.
The signal. The choice follows the access pattern, not fashion. Relationships, multi-row invariants and ad hoc queries point to relational. Very high write volume read by a single key, with simple queries, points to key-value or wide-column. The databases deep dive covers this choice in detail.
The trade-off. Relational databases scale writes vertically until you shard them by hand. Key-value stores scale out easily but push joins and some consistency guarantees into your application.
The follow-up. "What does your schema look like, and what is the primary key?" Have the table and its key ready; it shows you have thought about the queries.
Cache
What it does. Keeps frequently read data in memory, close to the application, so most reads skip the database.
The signal. A high read-to-write ratio, the same items read again and again, or a latency target the database cannot meet.
The trade-off. Staleness and invalidation. You must decide how long data may be out of date, how a write reaches the cache, and what happens when a hot key expires and many requests miss at once.
The follow-up. "What happens when the data changes?" and "What is your hit ratio, and what happens if the cache goes down?" A cold cache can send all traffic to a database sized for 10 percent of it. The caching deep dive covers write strategies and eviction.
Message queue
What it does. Holds messages from producers until consumers process them, decoupling the two in time and speed.
The signal. Work that does not need to finish before the user gets a response (sending email, transcoding video, updating a search index), spiky load that should be smoothed, or one event that several services must react to.
The trade-off. The work completes later, consumers must handle retries and duplicate deliveries, and you now have a backlog to monitor.
The follow-up. "What if a consumer fails halfway through?" The message is redelivered, so processing must be idempotent: running it twice must have the same effect as running it once.
CDN and object storage
What they do. Object storage keeps large files (images, video, backups) cheaply and durably. A CDN caches those files, and other static content, on edge servers near users.
The signal. Large or static content, or users spread across regions. Sending media through your app servers wastes their bandwidth and adds a long round trip for distant users.
The trade-off. Edge copies can be stale until they expire, and invalidating them takes time. Versioned URLs, where every change gets a new file name, sidestep that.
The follow-up. "How do uploads work?" A common answer: the app server hands the client a short-lived signed URL, and the client uploads straight to object storage, so large files never pass through your servers.
Worked example: a URL shortener
The prompt: users submit a long URL and get a short one such as sho.rt/aZ3kQ9p; anyone who opens the short link is redirected. Requirements gathered in the first minutes:
Create a short link, and redirect from it. Links never expire for this exercise.
100 million new links a month, and redirects outnumber creations about 100 to 1.
Redirects must be fast (tens of milliseconds) and highly available; a broken link is a visible failure.
Quick numbers: 100 million a month is about 3.3 million a day, or roughly 40 creations per second. Redirects at 100 times that are about 4,000 per second on average, more at peak. Over 10 years that is 12 billion links. With 7 characters from a 62-character alphabet (a to z, A to Z, 0 to 9) there are 62^7, about 3.5 trillion, possible keys, which is plenty.
client --> load balancer --> app servers --> cache --> database
|
+--> key generatorNow justify each block:
Load balancer and stateless app servers. Redirects must stay up when a server dies, and 4,000 requests per second at peak and growing is more than we want on one machine.
Database. The data is one mapping,
short_key -> long_url, read by key and never joined. Either a relational table withshort_keyas the primary key or a key-value store works; at about 40 writes per second, a single relational database with replicas is fine for years, and saying that is better than reaching for a distributed store you do not need.Key generator. Each new link needs a unique short key. Hashing the long URL and taking 7 characters risks collisions you must detect and retry. A simpler choice: a counter that hands out blocks of ids to each app server, with each id encoded in base 62. No collisions, no coordination per request.
Cache. Redirects are 99 percent of traffic and a small share of links get most clicks, so a cache keyed by
short_keyserves most redirects from memory. Since a mapping never changes once created, invalidation is not a problem here, which is worth pointing out.No queue yet, no CDN for the redirect. Nothing is slow enough to need a queue. Mention one if analytics (click counts) is added: record each click as a message and count asynchronously, so a redirect never waits on analytics.
Expected follow-ups: "Should the redirect be a 301 or a 302?" (A 301 is permanent and browsers cache it, which saves load but hides repeat clicks from your analytics; a 302 reaches you every time.) "What if the key generator goes down?" (Each server holds a block of ids, so it can keep creating links for a while; the generator itself runs with a standby.)
Mistakes that cost points
Drawing every block every time. A queue or CDN with no job in this problem tells the interviewer you are reciting a template.
Naming a block without its signal. "I'll add a cache" should come with "because reads outnumber writes 100 to 1."
Skipping the follow-up you can see coming. For each block you draw, decide in advance what happens when it fails.
Practice it
Drill: for a ride-sharing app, list which of the six blocks you would draw, the one-sentence signal for each, and one you would leave out and why. Then take Design a URL Shortener as a full interview and compare your design with this one. When you are ready for the next level, read Scaling Data: Replication, Partitioning and Consistency.
Practise this in a mock interview
Try what this lesson covers out loud: the AI interviewer asks one of these questions, follows up, and scores your answer.
- Design a URL ShortenerSystem Design · Medium
- Design a Rate Limiter ServiceSystem Design · Medium
- Design Live Score Alert FanoutSystem Design · Medium
- Design a Video Upload and Transcoding PipelineSystem Design · Medium
Read next
- Thinking in Systems: From One Server to Millions of Users
Explain why each part of a typical web architecture exists by growing one app from a single server to millions of users, naming what broke and what each fix costs.
7 min read
- The Fundamentals First: Networking, APIs and Estimation
Choose between REST, gRPC, WebSockets and polling, use the latency numbers that matter, and turn a vague prompt into reads per second, storage and bandwidth with back-of-the-envelope estimation.
7 min read
- System Design Interviews: The Quick Start
Know which system design interview you face and how depth expectations change by level, then deliver any design with a six-step, 45-minute framework whose estimates drive real decisions.
7 min read
- ML System Design Interviews: The Quick Start
Run an ML system design interview with an eight-step, 45-minute framework, from framing and labels to metrics, serving, drift and feedback loops, worked through on a harmful-comment classifier.
9 min read
