# A 118-character URL. 15 characters back.

> Designing a link shortener on Azure — and the one digit that decides whether you ever see your click stats.

- **Format:** short video, 13 steps, ~65 seconds
- **Topic:** Design a URL shortener on Azure — Functions, Cosmos DB and Front Door — built in the order you would actually think about it, including the 301 vs 302 trap.
- **Author:** Suthahar Jegatheesan (MSDEVBUILD)
- **Category:** Azure · Azure
- **Published:** 2026-08-13
- **Tags:** azure, systemdesign, azurefunctions, cosmosdb, azurefrontdoor, serverless, cloudarchitecture, urlshortener, backenddeveloper, microsoftazure, dotnet, interviewprep, az204, msdevbuild
- **Canonical URL:** https://blog.msdevbuild.com/shorts/azure-url-shortener-design/

---
## What you'll learn

- Why a link shortener is really two systems: one write, a thousand reads
- How the short code is made, and what Cosmos DB does when two people roll the same one
- Why the redirect must be 302 and not 301, and why Front Door answers most clicks

## Understand it one step at a time

### 1. One giant URL, one tiny link

Same destination, roughly 8 times fewer characters to type or paste. On the surface, that's the entire product in one sentence.

### 2. Two jobs, not one

Creating a short link happens exactly once per link. Following it happens thousands of times. Same feature, two completely opposite load shapes.

### 3. Where aZ8kQ2f comes from

Seven character slots, 62 possible values each — upper and lower case letters plus digits — rolled at random, giving 62^7 possible codes.

### 4. What if two people get the same code

Rare at 62^7 combinations, but not impossible. Let the database’s unique constraint be the referee — it already knows every code in use.

### 5. Saving it: Functions + Cosmos DB

The write path is Functions plus Cosmos DB, and it runs exactly once per link created — one small item, partitioned and keyed by the code itself.

### 6. Now somebody clicks the link

This read path can run a million times for a single link. Every millisecond of latency and every fraction of a cent here compounds fast.

### 7. Front Door answers most clicks

A popular link is cached at the Azure Front Door edge point of presence, so the redirect returns without ever waking your API code.

### 8. Cosmos DB: one point read

A Cosmos DB point read on the seven-character partition key. Not a query, not a scan — the single cheapest read operation a database offers.

### 9. 302, not 301

One HTTP status digit matters enormously. 301 tells the browser to cache the redirect forever — you lose click analytics and can never repoint it.

### 10. The whole design in one picture

One slim, infrequent write lane through Functions and Cosmos DB, one busy read lane, and an edge cache sitting in front of the busy one.

### 11. 92 of every 100 clicks

When a link goes viral, roughly 92 of every 100 clicks are answered straight from the Front Door cache — your bill stops tracking your traffic growth.

### 12. What beginners build vs what scales

The exact same three Azure services in both versions. Four small decisions — caching, redirect code, key design, read/write split — separate demo from product.

### 13. Tiny link. Serious design

It's the canonical read-heavy system design problem shrunk down to one feature — which is exactly why it shows up in interviews so often.

---

## The takeaway

**Tiny link. Serious design.**

One write, a thousand reads, and a cache in front of the reads — the shape of most systems you will ever build.
