Skip to main content

System Design Prompt: URL Shortener Like Bitly

Design a URL shortener like Bitly: hashing strategy, database choice, caching, analytics, and horizontal scaling to billions of URLs.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt asks the AI to design a Bitly-style URL shortener from first principles, sized to your traffic. You feed it [daily_urls] and [daily_redirects], and it works through ten areas: high-level architecture, the shortening algorithm, database choice and schema, a caching layer, read/write optimization, analytics, custom aliases, expiration, abuse prevention, and a scaling plan up to [target_scale].

The structure works because a URL shortener looks trivial until the numbers force tradeoffs. By passing [daily_redirects], you push the model to treat the redirect path as the read-heavy hot path it really is, which drives the caching design. The [hash_strategy] variable decides whether you get Base62-with-counter, hashing, or KGS-style key generation, and [cache_strategy] shapes the hot-URL layer. Grounding everything in capacity estimation keeps the answer honest about storage, bandwidth, and QPS rather than hand-wavy.

When to use it

  • You're prepping for a system design interview and want a structured URL-shortener walkthrough
  • You're actually building a link service and need to reason about the read-heavy redirect path
  • You want to compare [hash_strategy] options before committing to key generation
  • You need capacity math for storage, bandwidth, and QPS at [target_scale]
  • You're deciding between a write-optimized and read-optimized database schema
  • You want a defensible plan for caching, custom aliases, and collision handling

Example output

Expect a long-form design document: an architecture description (often with an ASCII or described diagram), the encoding algorithm with collision handling, a database schema, a caching section keyed to your [cache_strategy], capacity estimates with actual numbers derived from [daily_urls] and [daily_redirects], and a staged scaling narrative from one server to [target_scale]. It reads like an interview answer or an internal design RFC.

Pro tips

  • Set [daily_redirects] realistically — the read/write ratio it implies is the single biggest driver of the whole design
  • Try the prompt twice with different [hash_strategy] values to see the tradeoffs between counter-based Base62 and hashing
  • If you care about analytics, ask it to expand step 6; click, geo, and referrer tracking is easy to under-specify
  • Push it to show the capacity math, not just the conclusion — that's where interview answers and real plans earn trust
  • For [target_scale], give a concrete number; "web scale" produces vague answers, "10 billion URLs" produces sharding decisions
  • Treat the database recommendation as a starting point and ask it to justify the choice against your write-vs-read profile

Frequently Asked Questions

Is this prompt mainly for interview prep or real systems?
It works for both. The same structure that makes a strong interview answer — capacity estimation, hot-path caching, scaling stages — is exactly what you'd document before building. Real builds just demand more rigor on the database and abuse-prevention sections.
Which hashing strategy should I pick?
The `[hash_strategy]` default is Base62 encoding with a counter, which gives short, collision-free keys and predictable length. Hashing approaches like MD5-truncation are simpler but need collision handling, so run the prompt with each to compare the tradeoffs for your case.
Does it cover analytics like click tracking and geolocation?
Yes, step 6 covers analytics for clicks, geo, and referrer data. It tends to keep this section brief, so ask it to expand if analytics is a core requirement rather than a nice-to-have.
Will it give real capacity numbers?
It derives storage, bandwidth, and QPS estimates from the `[daily_urls]` and `[daily_redirects]` you provide, so accurate inputs produce useful math. Vague inputs produce vague estimates, so plug in your actual or target traffic.
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