01Chapter 1: Clarifying requirements and scopeEvery system design starts with a conversation, not a diagram. A URL shortener looks trivial: take a long URL, return a short one, redirect when someone visits it. The design changes a lot depending on the answers to a few questions. This chapter covers how to turn a vague prompt into a list of requ6 min read
02Chapter 2: Estimating traffic, storage, and code lengthThis chapter assumes you know basic HTTP, can read simple Python, and know that base62 uses 62 symbols per digit. You will turn the requirements from the previous chapter into numbers: requests per second, bytes on disk, memory for a cache, and the number of characters in a short code. These numbers6 min read
03Chapter 3: Designing the APIThis chapter defines the HTTP interface of the URL shortener: which endpoints exist, what they accept and return, and which status codes they use. It assumes you know HTTP methods, status codes, and headers, and can read short Python programs. The requirements and capacity chapters established the s5 min read
04Chapter 4: Base62 encoding and decodingA URL shortener has to turn something it can count or compute, such as a database ID or a hash, into a short string that is safe in a URL path. Base62 is the usual choice. This chapter explains how it works, implements it, and covers the edge cases that cause bugs in production.6 min read
05Chapter 5: Generating short codes: hash, counter, or randomThis chapter compares three ways to produce the short code in a URL shortener. It assumes you know basic HTTP, have used a relational or key-value database, understand hashing and number bases at a high level, and can read simple Python. The earlier chapters on capacity estimation and base62 encodin5 min read
06Chapter 6: Handling collisionsA collision happens when two different long URLs get the same short code. This chapter shows when collisions occur, how often, how to detect them safely, and how to recover.7 min read
07Chapter 7: Data model and choosing a datastoreThis chapter assumes you have read the earlier chapters on requirements, capacity estimation, API design, and short code generation. You should know basic SQL, understand what a primary key and an index are, and be able to read simple Python. Here you will design the table that stores links and deci7 min read
08Chapter 8: Redirecting: 301 versus 302This chapter covers the redirect step of a URL shortener: what the server sends back when someone opens a short link, and why the choice between a 301 and a 302 status code affects caching, analytics, and your ability to change links later. It assumes you know basic HTTP (methods, status codes, head6 min read
09Chapter 9: Speeding up reads with a cacheA URL shortener spends nearly all of its time on one operation: turning a short code into a long URL and sending a redirect. This chapter adds a cache in front of the database to serve that operation. It covers where the cache sits, how big it must be, how entries leave it, and what goes wrong when 5 min read
10Chapter 10: Allocating unique IDs across many serversThis chapter assumes you have read the earlier chapters on base62 encoding and short code generation. You should be comfortable with a relational table, an atomic UPDATE, and basic threading in Python.5 min read
11Chapter 11: Scaling storage with replication and shardingThis chapter assumes you know basic SQL, HTTP status codes, and the cache-aside pattern from the caching chapter. It also assumes you have seen the urls table and the idea of allocating IDs in ranges. Here you will learn how to grow the storage layer past one machine.7 min read
12Chapter 12: Custom aliases and expiring linksThis chapter adds two features to the shortener's core path: user-chosen aliases and links that stop working at a set time. Both look small, but they add edge cases to code generation, the data model, caching, and redirects.6 min read
13Chapter 13: Collecting click analyticsThis chapter adds click analytics to the redirect path. It assumes you have read the chapters on redirect semantics (301 versus 302) and caching, and that you know basic SQL and Python. It does not cover abuse protection or availability in depth. Those have their own chapters.5 min read
14Chapter 14: Preventing abuse: rate limits, validation, and enumerationA URL shortener accepts links from strangers and sends other strangers to them. That makes it a useful tool for spammers, phishers, and scrapers. This chapter covers three defenses: validating what users submit, limiting how fast clients can call the API, and making short codes hard to guess in bulk6 min read
15Chapter 15: Availability, failure modes, and trade-offsThis chapter closes the design. You already have the pieces: code generation, a datastore, a cache, replicas, and shards. Here you ask what happens when each piece fails, and which compromises you accept to keep the service up. It assumes you have read the earlier chapters on caching, redirects, rep6 min read