Skip to main content

Claude/ChatGPT Prompt to Design a URL Shortener at Scale

Full system design for a URL shortener at 100M new URLs/day: code generation, storage, caching, rate limiting, and global latency.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

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.

Frequently Asked Questions

Does this produce real capacity numbers or just a generic diagram?
It produces back-of-envelope numbers tied to your inputs, including code-length math for `[write_volume]` and a storage capacity estimate. Forcing concrete numbers up front is the point, because it reveals whether the cache or the datastore is the real constraint.
Does it help decide between a base62 counter and a hash for short codes?
Yes. Deliverable 2 compares a base62 counter against a hash with explicit collision handling and length math. Decide this before storage, since the generation strategy dictates the schema and much of the downstream design.
How is the caching layer sized?
It is sized against your `[read_ratio]` with an eviction policy and a `[latency_target]` budget. Use a realistic read ratio, because understating reads is exactly how a shortener falls over on the read path the moment one link goes viral.
Is this useful for a system design interview?
Yes, the URL shortener is a canonical interview question, and the deliverables map to what reviewers probe: code generation, storage, caching, rate limiting, and global latency. Ask the AI to defend each number so you can rehearse the follow-up questions an interviewer asks.
Does it address abuse and multi-region serving?
Yes. It includes per-user and per-IP rate limiting with abuse protection, plus global replication across the `[regions]` you specify with named failure modes. Pressure-test that failure section, since ignoring cache-miss storms or a region outage leaves a design that only looks complete.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in System Design Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support