I describe the URL-shortener design this way: writes turn a long URL into a 7-character code (base62 of a unique id); reads look it up and return a 301.
I use a viral URL-shortener example where a link gets a billion clicks a day; at the initial stage, a viral link fills the queue, p99 hits 900 ms and the database tips over.
I describe the API replication step this way: the API is stateless, so put a load balancer in front and autoscale replicas.
I say Redis serves hot URL codes in under a millisecond and absorbs ~95% of reads.
I describe the sharding and ID-leasing step this way: split the URL table by hash(code) across shards, and lease each API its own block of IDs; writes never wait on each other.
I describe the edge and analytics step this way: CDN edges answer cached redirects near users; click events stream to Kafka, so analytics never slows a redirect.
I summarize my scaling order this way: Each stage fixes the bottleneck the previous one exposed. That order is the whole answer.
My URL-shortener rule of thumb is to optimise the read path first: the create path runs once, while the redirect runs millions of times.
My URL-shortener sequence moves from one API server and Postgres, to stateless replicas, hot-read caching, sharding and leased IDs, then edge redirects and asynchronous click analytics. The database remains the bottleneck after adding API replicas, which is why caching precedes sharding.
I argue against jumping to microservices on day one: teams may have spent two years paying for complexity they didn't need.
I present an ERP scaling sequence of 8 moves, starting with an app on a single VM.
My rule is to add each move only when the last one starts to hurt.
For move 1, I describe the setup this way: App and database on one machine. Simple and cheap, until month-end jobs choke the CPU and one crash blocks every team.
For move 2, I describe the setup this way: Move the database to its own managed server. Each tier now scales on its own, and the app tier becomes stateless and ready to clone.
For move 3, I describe the setup this way: Health checks route around a dead box, autoscaling adds servers at 9 am, and SSO sessions live in a shared store like Redis.
For move 4, I describe the setup this way: The primary takes every write; reports and BI dashboards read from replicas. Heavy reporting stops slowing down writes, and a replica can be promoted if the primary fails.
For move 5, I describe the setup this way: Redis answers the same reads before the database is asked (cache-aside: miss, read the DB, fill). PDFs, JS and images come from the edge, close to users.
For move 6, I describe the setup this way: Each customer's data lives on one shard. Big tenants stop slowing the rest, and EU tenants can stay in the EU.
For move 7, I describe the setup this way: Reply to the user now; sync CRM, send email and run slow jobs later. The bus soaks up traffic spikes, and failed jobs retry.
For move 8, I describe the setup this way: One service per business domain (billing, orders, inventory), each with its own database. Teams ship alone and you scale only the hot service.
My ERP progression is a single-machine monolith, database separation, load balancing, read replicas, cache and CDN, tenant sharding, asynchronous event processing, and finally domain-level microservices. I treat the stages as responses to observed bottlenecks, not a mandate to adopt every pattern upfront.
I use architecture patterns to solve problems a system actually has, not as a checklist of fashionable components. My posts on architecture maturity, scaling, and design reviews all emphasize matching complexity to the needs of the system and team.
I present a microservices reference architecture as 12 building blocks on one map, with a request path down the middle and the platform around it; it is a reference, not a system-specific prescription.
I divide the architecture into a request path of blocks 1–7 and a surrounding platform of blocks 8–12.
- I describe the request path as edge DNS and CDN; load balancing with Nginx or HAProxy across healthy instances; an API gateway as a front door for routing and rate limits; identity tokens checked by the gateway; an Istio or Envoy service mesh adding mutual TLS and retries; Docker containers kept running by Kubernetes; and SQL, NoSQL, and Redis for transactions, documents, and hot reads.
- I describe the surrounding platform as RabbitMQ or SQS queues holding commands for one worker; Kafka event logs replayed by multiple consumers such as search and analytics; settings kept outside code with Vault injecting secrets at runtime; metrics, logs, traces, and alerts brought together through observability; and Jenkins building and testing changes before rolling Docker images out to Kubernetes.
I ask readers which block they would add or drop for their own system, treating the architecture as a prompt for system-specific choices.
I present 16 recurring building blocks as a way to read architecture diagrams and prepare for system design interviews; I say these are trade-offs to choose, not products to install.
- I group the building blocks into five areas: Traffic & Edge (CDN, API Gateway, Rate Limiting, Load Balancers); Data Storage (Database, Object Storage, Caching); Distribution & Scaling (Partitioning, Consistent Hashing, Replication); Async & Data Flow (Message Queues, Event-Driven Architecture, Stream Processing); and Architecture & Reliability (Microservices, Fault Tolerance, Observability).
I explain that a CDN serves static content near users; an API Gateway routes, authenticates, and throttles; rate limiting spends a token per request and returns 429 when tokens run out; and load balancers spread traffic across healthy servers.
I describe databases as systems of record using SQL or NoSQL, object storage as cheap durable blobs stored by key, and caching as serving hot reads in microseconds after a miss.
I describe partitioning as splitting data by key so writes scale past one node, consistent hashing as moving only nearby keys when a node is added, and replication as copying writes to scale reads and survive failures.
I describe message queues as buffering work so producers do not wait, event-driven architecture as letting many services react to one publication, and stream processing as computing on events as they flow in.
I describe microservices as independently deployed and scaled services that own their data; fault tolerance as using circuit breakers, retries, and fallbacks to stop failures spreading; and observability as using logs, metrics, and traces to show what is happening inside.
I frame system design as explaining trade-offs rather than finding one universally best answer: engineers should choose the downside they can live with.
- I group 16 trade-offs into Data & Consistency (Consistency vs Availability; Strong vs Eventual; SQL vs NoSQL; Normalized vs Denormalized), Performance & Flow (Latency vs Throughput; Cached vs Fresh; Batch vs Stream; Push vs Pull), Scale & Architecture (Vertical vs Horizontal; Monolith vs Microservices; Replication vs Partitioning; Stateful vs Stateless), and Communication & Cost (Sync vs Async; At-least-once vs Exactly-once; Serverless vs Containers; Redundancy vs Cost).
I contrast consistency and availability as refusing when unsure versus answering anyway; strong and eventual consistency as always latest versus fast and catching up; SQL and NoSQL as schema and joins versus flexibility and scale-out; and normalized and denormalized data as one copy versus faster reads with copies.
I contrast latency and throughput as speed for each request versus more requests in total; cached and fresh reads as 2 ms and maybe stale versus 40 ms and correct; batch and stream as cheap tonight versus live now; and push and pull as instant updates versus simple polling.
I contrast vertical and horizontal scaling as one bigger box versus many smaller ones; monolith and microservices as simple to start versus shipping parts alone; replication and partitioning as surviving failures versus adding capacity; and stateful and stateless systems as fast and sticky versus any server being able to answer.
I contrast synchronous and asynchronous communication as simple and waiting versus decoupled and moving on; at-least-once and exactly-once delivery as possible duplicates versus slower exactness; serverless and containers as pay per use versus always warm; and redundancy and cost as surviving outages versus a smaller bill.
I present ten principles for systems that bend instead of break, saying systems rarely fail because of the tech stack alone but because a principle was skipped.
I describe modularity as splitting systems into bounded services such as auth, user, order, and payment, with each team shipping its own; my test is whether one can ship without the others.
I describe encapsulation as keeping logic behind a simple public API so callers depend on what it does, not how; I ask whether it could be rewritten without telling callers.
I describe coupling and cohesion as keeping related behaviour together inside a component and having few links between components; I ask whether one change stays in one place.
I name dependency injection, events and pub/sub, Kafka and RabbitMQ message queues, and OpenAPI contracts as coupling strategies; I ask who breaks if a service is slow.
I recommend information hiding for decisions likely to change, such as the payment provider and fraud rules, and ask what decision might change next year.
I recommend immutability: never update in place, but write new versions, which I say means fewer race conditions and a free audit trail; I ask whether the value's history can be replayed.
I recommend designing for failure with timeouts, retries with exponential backoff, circuit breakers, and bulkheads, and ask what happens when a call never returns.
I describe stateless and idempotent services as allowing any instance to serve any request, with state in Redis or a database and idempotency keys making retries safe; I ask what happens if a request arrives twice.
I recommend observability from day one through logs, metrics, and traces, naming OpenTelemetry, Prometheus, and Grafana; I ask whether on-call can find the slow query fast.
I recommend security by design through least privilege, validation at every boundary, mTLS between services, and treating inputs as untrusted by default; I ask what happens if input is malicious.
I argue that Airbnb's architecture was forced, one bottleneck at a time, rather than designed upfront.
In my account, Airbnb began with a single-server monolith: the web server, app logic, and database were on one machine until it could not handle load.
I describe horizontal scaling of the web tier as the next step: more web servers behind a load balancer while retaining one shared database.
I say sharding and read replicas appeared only when the database became the bottleneck, splitting users, listings, and reservations across separate shards.
In my sequence, microservices came fourth, breaking the monolith into auth, booking, listing, and search services only after the shared-database model ran out of room.
I describe async queues as the next step, offloading long-running work like email and inventory updates.
I describe distributed caching and search using Redis in front of Elasticsearch to make property search fast at scale.
I say circuit breakers arrived when service-to-service calls were common enough that one failing service could cascade into an outage.
I place global CDN and regional clusters second to last, once traffic was actually global.
I place service mesh and full observability last, naming Envoy, Istio, Prometheus, and Jaeger; my rationale is that you can't operate what you can't see, and there was nothing worth seeing until the system was complex.
I argue that every pattern is correct at some point and premature before that point; copying Airbnb's stack from day one skips the sequencing that made it necessary.
I once watched a five-person startup adopt agentic architecture, a service mesh, and data mesh in the same quarter, despite lacking the problems those patterns were built to address.
Six months later they'd rebuilt all three as a monolith with a Postgres database, because that's what a five-person team actually needed.
I argue that knowing which of the 15 patterns apply right now is the actual skill, rather than merely knowing they exist.
I describe monolithic architecture as best for small applications and quick development, not a legacy embarrassment; plenty of profitable companies run on one.
I describe microservices as suited to large, complex systems needing independent scalability, not teams still finding product-market fit.
I describe event-driven architecture and CQRS as solving real-time decoupling and high-performance read models, respectively.
I describe serverless as trading control for cost-efficiency on genuinely variable workloads.
I describe RAG, agentic, and multi-agent architecture as tools for knowledge retrieval, autonomous execution, and collaborative AI problem-solving, not a checklist to complete because they're trending.
I argue architecture maturity is measured by how many patterns a team correctly avoided because its system did not need them yet.
I describe a URL shortener as write-light: every link is created once and read about 100 times.
In my viral-traffic example, a link gets clicked a billion times a day: 11,600 redirects every second, with spikes ten times higher.
For Stage 1 of my URL-shortener design, the stateless API is replicated behind a load balancer; three replicas fix CPU pressure and p99 drops from 900 ms to 160 ms, though the database is still hot.
For Stage 2, I cache hot links in Redis; it absorbs ~95% of reads, and p99 falls to 12 ms.
For Stage 3, I shard by hash(code) and give every server its own ID range so writes stop waiting on each other and codes never collide.
For Stage 4, I put redirects at the CDN edge and count clicks in Kafka in the background so analytics never slows a redirect.
I frame 301 versus 302 as a product decision: a 301 gets cached by browsers, saves load, but hides repeat clicks from analytics.
I present eight architecture styles and argue that knowing which one a system uses, and why, turns a code review into a design review.
I describe a monolith as one codebase and one deploy, best for MVPs and small teams, but scaling and failing as one unit.
I describe layered architecture as UI → business → persistence → database, with each layer calling only the one below; it suits classic enterprise web apps, though changes ripple through every layer.
I describe Hexagonal / Clean architecture as core logic connected to databases, UIs, and queues through ports and adapters; it supports testable domain logic and lets teams swap Postgres for DynamoDB without touching the core.
I describe Microkernel / Plug-in architecture as a minimal core extended by plug-ins, suited to IDEs, browsers, and product platforms, with stable plug-in contracts as a trade-off.
I describe microservices as small services that own their data and deploy independently, suited to many teams at scale.
I describe Serverless (FaaS) as event-triggered functions that scale to zero and bill per run, with an idle cost of $0 for spiky, event-driven workloads.
I describe Event-Driven architecture as producers publishing to a broker such as Kafka, SNS, or Pub/Sub, with consumers reacting asynchronously; it suits real-time data pipelines.
I describe CQRS as separate write (command) and read (query) models that can be scaled independently, suited to read-heavy domains but requiring management of eventual consistency.
I describe the pattern across all eight architecture styles as trading simplicity for independent scale.
Related: api gateway and api design, load balancing and traffic routing, database selection and performance