system-design

Every App You Love Was Designed Before a Single Line of Code Was Written

System design isn't a topic for senior engineers. It's the invisible architecture behind every app that scales, survives, and stays fast under pressure.

5 min read

The Question Nobody Asks First

Most engineers ask: "What framework should I use?"

The engineers who built Stripe, Notion, Linear, and Netflix asked something different first:

"What happens when this breaks at 3AM with a million users?"

That question is system design. And it's not a senior engineer's concern. It's the foundation every application stands on — whether you planned for it or not.

What System Design Actually Is

System design is the set of decisions you make about how your application behaves under real-world conditions.

Not ideal conditions. Real ones.

  • What happens when your database gets 50,000 requests per second?
  • What happens when one server dies mid-transaction?
  • What happens when two users edit the same record at the same time?
  • What happens when your API gets hammered by a bot at 2AM?

Every application on the internet is constantly answering these questions — whether the engineer who built it thought about them or not.

The ones who thought about them are called Google, Amazon, and Stripe.

The ones who didn't are called postmortems.

The Invisible Layer

Here's what's interesting: users never see system design. They see speed. They see reliability. They see the app working when they need it.

When you open Notion and a page loads in 200ms — that's caching.
When Stripe processes your payment even though one data center just went down — that's replication and failover.
When Netflix streams to 260 million people on Friday night without buffering — that's load balancing and CDN.
When your bank account never shows the wrong balance — that's ACID transactions.

None of these are features. They're architectural decisions made before the first line of application code.

One Concept, Deep: Caching

There are 80 core system design topics. We'll go deep on all of them over time.

Today: caching — because it's the single most impactful concept in system design, and every application on the internet uses it, usually badly.

The problem it solves:

Your API gets 10,000 requests per second. Each request hits your database. Your database can handle maybe 5,000 queries per second. You've just invented a failure.

The insight:

Most of those 10,000 requests are asking for the same data. The same product page. The same user profile. The same configuration. Reading the same row from PostgreSQL 10,000 times a second when the answer doesn't change is waste — pure, expensive waste.

A cache stores the result of expensive operations so you can serve them instantly the next time without re-computing.

How it works:

Request → Check Cache
├── HIT → Return cached data (microseconds)
└── MISS → Query Database → Store in Cache → Return data

The first request pays the full cost. Every request after it is nearly free.

Real implementation with Redis and Node.js:

javascript

const redis = require('redis'); const client = redis.createClient(); async function getUserProfile(userId) { const cacheKey = `user:${userId}`; // Check cache first const cached = await client.get(cacheKey); if (cached) { return JSON.parse(cached); // Cache HIT — ~0.1ms } // Cache MISS — go to database const user = await db.query( 'SELECT * FROM users WHERE id = $1', [userId] ); // Store in cache for 5 minutes await client.setEx(cacheKey, 300, JSON.stringify(user)); return user; }

This is exactly how Uber, Twitter, and GitHub serve user data at scale. Redis sits in front of PostgreSQL. The database handles writes. Redis handles reads.

The tradeoff you must understand:

Caching introduces staleness. If a user updates their profile, the cache still holds the old version for up to 5 minutes. This is called eventual consistency — a concept we'll go deep on in a future post.

For a user profile, 5-minute staleness is fine. For a bank balance, it's catastrophic. System design is knowing the difference.

Where caching shows up across the stack:

Layer

Tool

What it caches

Application

Redis / Memcached

Database query results, sessions

Database

PostgreSQL buffer pool

Frequently accessed pages

HTTP

Nginx, Varnish

Full responses

Global

CDN (Cloudflare, Fastly)

Static assets, edge responses

Browser

HTTP Cache-Control

Images, JS, CSS

Every layer is a caching decision. Every caching decision is a system design decision.

Build It. Break It. Understand It.

Here's a small exercise that will make caching click permanently:

Step 1 — Build a simple Express API that queries a database for a user by ID. Time the response.

Step 2 — Add Redis in front. Implement the cache-aside pattern above. Time the response again.

Step 3 — Update the user in the database. Query the API again. Notice it still returns stale data.

Step 4 — Add cache invalidation: when a user updates, delete the cached key.

javascript

async function updateUser(userId, data) { await db.query('UPDATE users SET ... WHERE id = $1', [userId]); await client.del(`user:${userId}`); // Invalidate cache }

You just implemented cache-aside with invalidation — the pattern Netflix, GitHub, and Shopify use in production. You also just discovered the two hardest problems in system design:

Cache invalidation and naming things.

That's not a joke. Knowing when to invalidate, what to invalidate, and what the side effects are — that's where senior engineers spend real time.

Why This Series Exists

System design is not a topic you study for interviews and forget.

It's the lens through which every engineering decision looks different. When you understand caching, you stop treating your database as a free resource. When you understand replication, you stop assuming your database will always be there. When you understand rate limiting, you stop assuming your API can absorb anything.

Every concept in the 80-topic list above exists because a real company ran into a real problem and built a real solution. Some of those solutions became Redis. Some became Kafka. Some became Kubernetes.

We're going to go through all of them — grounded in real systems, real companies, and real code you can run yourself.

Next: Load Balancing — how Cloudflare, AWS, and Nginx decide which server handles your request, and what happens when they get it wrong.

This is post 1 of the System Design series. Each post covers one concept, deep — with real examples, real tradeoffs, and code you can actually use.