What this prompt does
This prompt has the AI act as a senior systems architect and design a URL shortener tightly enough to build, with real numbers instead of hand-waving. You provide the [write_volume], the [read_ratio], the [latency_target], and the [regions]. It returns the API shape, a short-code generation strategy with collision handling and length math, a storage choice with schema and capacity estimate, a caching layer sized against the read ratio, rate limiting and abuse protection, and analytics, aliases, expiry, and global replication with named failure modes.
The structure works because "simple" shorteners die on the read path once they go viral, and forcing capacity math up front exposes whether caching or the datastore is the real constraint. [write_volume] drives the short-code length math and storage sizing, [read_ratio] sizes the cache and hot-read path, [latency_target] sets the budget the caching layer must hit, and [regions] determines the global replication design.
When to use it
- You're preparing for a system design interview and want to rehearse this classic.
- You're scoping a real shortener and need capacity math before committing a design.
- You want to decide base62 counter versus hash with explicit collision handling.
- You need a cache sized against a read-heavy ratio with an eviction policy.
- You want rate limiting and abuse protection designed in, not bolted on.
- You need a multi-region replication plan with named failure modes.
Example output
You get an architecture writeup with a diagram description and back-of-envelope numbers: API endpoints for create, resolve, custom alias, and expiry; short-code generation comparing base62 counter versus hash with collision handling and code-length math for [write_volume]; a SQL-versus-NoSQL storage choice with schema and a capacity estimate; a caching layer for hot reads sized against [read_ratio] with eviction and a [latency_target] budget; per-user/per-IP rate limiting and abuse protection; and analytics, custom aliases, expiry, replication across [regions], and named failure modes.
Pro tips
- Decide the short-code generation strategy before storage — base62 counter versus hash dictates everything downstream, including schema and collision handling.
- Set
[write_volume]precisely, since it drives the code-length math and storage capacity estimate; a vague volume yields a vague sizing. - Use a realistic
[read_ratio]because the cache is sized against it; under-stating reads is how a design dies the moment a link goes viral. - Treat
[latency_target]as a hard budget the caching layer must meet, and ask the AI to show the cache-hit math that supports it. - Pressure-test the failure modes section; a design that ignores cache-miss storms or a region outage looks complete but isn't.
- For interview prep, ask the AI to defend each number out loud so you can rehearse the follow-up questions a reviewer would ask.