Design URL Shortener

Read-heavy distributed URL shortening service with caching, replication, rate limiting, async analytics, and ID generation.

Functional requirements

  • Users can submit a long URL and receive a unique short code (e.g., prism.io/aB3xY) via the URL Shortening Service.
  • Visiting a short URL is resolved by the Redirection Service and returns an HTTP 301/302 redirect to the original long URL.
  • Users can optionally specify a custom alias; the system guarantees global uniqueness at creation time.
  • Short URLs expire after a configurable TTL (default: 1 year); a Cleanup Worker removes expired links, which then return 410 Gone.
  • Users can view click analytics (total clicks, referrers, geographic distribution) served from the analytics store.
  • Authenticated users can manage (update target, deactivate, delete) their own short URLs via the User Service.
  • The system blocks creation of short URLs pointing to known malicious or phishing domains, with CAPTCHA/bot-protection on suspicious flows.
  • Bulk short-URL creation is supported via a CSV upload API; an Export Worker produces downloadable CSV exports to object storage.
  • QR code generation is available for any short URL on demand.
  • Every redirect emits a click event to Kafka, consumed asynchronously by the Analytics Worker; notifications are delivered via a Notification Worker.

Non-functional requirements

  • Availability: 99.99% uptime across multiple availability zones and regions; the redirect path keeps serving cached mappings during partial DB or single-zone outages.
  • Latency: redirect response under 10 ms at p99 when served from the global Redis cache; under 50 ms on cache miss to a regional replica.
  • Scalability: support 10 billion active short URLs and 100,000 redirect requests per second on a stateless, horizontally scalable application layer.
  • Throughput: the messaging layer (Kafka) sustains high-throughput click/event fan-out without back-pressuring the redirect path.
  • Durability: all URL mappings persisted durably in Cassandra and replicated across at least 3 availability zones; backups and exports stored in object storage (S3/GCS).
  • Consistency: eventual consistency acceptable for analytics counters and replicas; strong consistency required for creation uniqueness.
  • Performance: 99% of redirect requests served from an in-memory Redis or CDN cache layer (cache-first).
  • Security: WAF/DDoS protection at the edge, per-IP and per-user rate limiting, input validation and blocklist checks, plus CAPTCHA/bot protection on creation.
  • Geo-distribution: Geo-DNS plus CDN edge nodes and multi-region read replicas serve redirects with minimal RTT worldwide.
  • Observability: real-time metrics, logs, and traces (Prometheus, ELK/OpenSearch, Jaeger) with Grafana dashboards and Alertmanager p99 alerting within 30 seconds.

How the design evolves

Stage 1: Monolith MVP

Start with one stateless-free monolith and one metadata database to validate the core create/redirect flow. Understand why a single node is simple but a single point of failure with no caching, protection, or scale-out.

What was missing: No edge protection, no cache, no replicas, no async pipeline, no observability — one service does everything.

Why that's risky: The bottleneck is the single monolith+DB: any spike, bug, or hardware failure takes the whole service down, and every redirect pays full DB latency.

What gets added: Nothing yet — this is the MVP baseline we will evolve.

Trade-offs: Trivial to build and operate, but not production-ready or globally fast.

Stage 2: Global Edge: DNS, CDN, WAF & Anycast LB

Put a safe, fast global front door on the service: Geo-DNS for regional routing, a CDN for static/edge caching, a WAF/DDoS layer for protection, and an Anycast load balancer feeding an API Gateway and stateless app server.

What was missing: No global routing, no edge cache, no attack protection, and the app talked straight to the DB.

Why that's risky: The bottleneck was the exposed origin: distant users paid full RTT, repeat reads hammered the origin, and there was zero DDoS/WAF protection.

What gets added: Geo-DNS, CDN, WAF/DDoS edge, Anycast Load Balancer, an API Gateway and a stateless application server.

Trade-offs: More moving parts at the edge and a slightly longer request path in exchange for safety and global speed.

Stage 3: Multi-Region Stateless App Layer + Rate Limiting

Make the application layer highly available and abuse-resistant: run stateless app servers behind API Gateways in two availability zones and add a Rate Limiter Service so a whole zone can fail and bots can't exhaust capacity.

What was missing: Only one zone of app compute and no request quotas — a zone outage meant a full outage, and bots could flood create/resolve.

Why that's risky: The bottleneck was single-zone app compute plus unthrottled traffic: one AZ failure or one abusive client could saturate everything.

What gets added: A second availability zone (API Gateway + stateless app servers) and a Rate Limiter Service enforcing per-IP/per-user quotas.

Trade-offs: More deployment and quota-tuning complexity for real HA and protection.

Stage 4: Core Services Decomposition

Break the monolith into independently scalable core services — URL Shortening (create), Redirection (resolve), User (auth), Analytics (stats) — so the hot read path and the write path scale separately and teams can own each service.

What was missing: The app servers still bundled create, resolve, auth and stats into one code path, so one concern's load or bug affected all of them.

Why that's risky: The bottleneck was coupling: the 90%-of-traffic resolve path shared capacity and deploys with rare, heavy create/auth work.

What gets added: Four dedicated core services (URL Shortening, Redirection, User, Analytics) called over gRPC, each scaled independently.

Trade-offs: More services and gRPC calls to operate and trace, in exchange for isolation and independent scaling.

Stage 5: Cache-First Reads + Multi-Region Replicas

Make redirects cache-first and scale reads globally: add a global Redis cluster in front of the Redirection Service, a session store to keep the app stateless, and multi-region read replicas so the write primary is never the read bottleneck.

What was missing: Every resolve still read a database, and all reads pointed at the single primary.

Why that's risky: The bottleneck was database reads on the hottest path: the primary couldn't serve 100k redirects/sec at <10ms, and popular links caused read storms.

What gets added: A global Redis cache (hot mappings), a Redis session store, and two multi-region read replicas fed by primary replication.

Trade-offs: Eventual consistency on replicas and cache-invalidation complexity in exchange for large read scale.

Stage 6: Kafka Event Backbone + Worker Services

Decouple all heavy background work behind a Kafka event backbone with dedicated worker pools (redirection, analytics, cleanup, notification, export), plus a ClickHouse analytics store and object storage for backups/exports.

What was missing: Analytics, cleanup, notifications and exports still ran synchronously and shared the transactional DB, adding latency and contention.

Why that's risky: The bottleneck was doing durable, expensive work on the request path: click writes slowed redirects and a stalled job could back-pressure users.

What gets added: A Kafka cluster, five worker pools, a ClickHouse/Druid analytics DB, and S3/GCS object storage for backups and exports.

Trade-offs: Eventual consistency for analytics and more infrastructure to run for durability and throughput.

Stage 7: Observability & Operations

Add full observability across the multi-region platform — Prometheus metrics, ELK/OpenSearch logs, Jaeger traces, Alertmanager alerts and Grafana dashboards — so regressions are detected, diagnosed and paged before users feel them.

What was missing: The distributed system had no unified metrics, logs, traces, alerting or dashboards.

Why that's risky: The bottleneck was blindness: with many services across regions, a p99 regression or partial outage could go unnoticed until users complained.

What gets added: Prometheus, ELK/OpenSearch, Jaeger, Alertmanager and Grafana, wired to async telemetry from every component.

Trade-offs: More systems and signal to manage, plus alert-tuning to avoid noise.

Stage 8: Third-Party Integrations & Full Production

Complete the production system by integrating external providers — SendGrid, Twilio, Cloudflare Turnstile, Cloudflare bot protection and Stripe — so comms, human-verification, edge security and billing are handled without building them in-house.

What was missing: No email/SMS delivery, no CAPTCHA/bot verification, and no billing integration.

Why that's risky: The bottleneck was missing business/security capabilities: no way to notify users, stop automated signups, or monetize — and building them in-house would be slow and risky.

What gets added: SendGrid, Twilio, Cloudflare Turnstile, Cloudflare bot protection and Stripe, called over REST from the relevant services/workers.

Trade-offs: Vendor dependencies, cost and data-sharing considerations in exchange for speed to market and robustness.

Frequently asked questions

How do you handle hot keys in a URL shortener?

Introduce key salting for popular URLs, cache hot entries aggressively, and shard by hashed key prefix.

Which consistency model is acceptable for reads?

Eventual consistency for replicas is acceptable with primary writes and fallback when lag increases.

How do you prevent thundering herd on cache miss?

Use request coalescing, soft TTLs, and background refresh to avoid stampedes.

Why keep the MVP architecture simple?

A single service and database reduce complexity and help validate core functionality quickly.

How does rate limiting protect the shortener?

Rate limiting prevents abusive spikes and preserves capacity for legitimate traffic.

Why move analytics to an async queue?

Async analytics decouple heavy writes from the request path and keep redirect latency low.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Design Your Own System NEW
System Architectures
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Phase
Design Your Own System
Phase 01: Thinking in Systems
Upcoming

Components

User
CDN
Load Balancer
Server
Cache
Database
Blob Storage
Search Index
Queue
Worker
Rate Limiter
Service
API Gateway
Reverse Proxy
WebSocket Server
Third-party API

Inspector

Notes
Use clear names so your design intent is easy to understand.
Good
Name by business meaning
"Order API", "Restaurant Service"
Avoid
Generic names = zero signal
"Server 1", "API", "Queue"
A short description for each component makes feedback much better.
100%
Start by identifying:
  • Users & entry points
  • APIs & services
  • Databases & storage
  • Traffic flow & scale

Round 1 of 4 Architecture Design

Run a simulation to see results.

Time Remaining
60:00
System Design Interview

What are the core functional requirements?
What are the key non-functional constraints?

Questions

Start Evaluation to unlock questions.

Components Added
No components listed
Click "+ Add" to document components introduced in this stage.
Design Decisions

Click Simulate to run your design and see results here.

Internal notes — not shown to learners.

EVALUATE MODE

Test yourself like it's the real thing.

A structured 4-module evaluation that mirrors how top companies assess system design candidates.

Architecture Design
Draw your system on the canvas. Define components, connections, and data flow.
FR & NFR Requirements
Answer functional and non-functional requirement questions about your design.
MCQ Round
Multiple choice questions testing your depth on the chosen system.
Tradeoff Analysis
Justify your design decisions and defend your architectural tradeoffs.
AI Report Generated
A R S
Used by engineers preparing for FAANG & top-tier companies
Choose a Problem
No problem selected
  • 30 min
  • 45 min
  • 60 min
Round 2 of 4
MCQ Round
Answer multiple-choice questions based on your design.

Exit Interview?

You're in the middle of an interview session. Leaving now will end your current attempt.

Your progress will be saved.

Open a saved design

Select a design to load into the canvas.

My Evaluations

Your past evaluation sessions

Here’s a simple request flow that follows the expected layer order.

External User
→
Edge CDN → API Gateway → Load Balancer
→
Compute App Servers / Services
→
DataAccess Cache
→
Storage Database / Search Index
→
Async Queue → Worker

Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

Evaluation Instructions

Read the rules carefully before starting. The test auto-submits on refresh.

Before you start

  • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
  • Don't forget to answer Functional Requirement and Non Functional Requirements.
  • When satisfied with your design, click Next to lock it and view the questions.
  • Please answer final step questions to complete the evaluation.

Dos

  • Do read each question carefully before answering.
  • Do include required components to maximize component coverage.
  • Do save a copy of your design if you want to keep it before submission.

Don'ts

  • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
  • Don't switch app modes or open another tab while the evaluation is running.
  • Don't attempt to edit the design after clicking Next; the workspace will be locked.

All the best!!

Confirm

Input

Notice

Evaluation Report:

Evaluation Complete

Generating Your Report

Hang tight — our AI is evaluating your design…

Did you know?

Loading…

Share feedback

Tell us what worked well and what we can improve.

Let's personalize this

Answer a couple of quick questions so we can tailor your journey and missions.

You can change this anytime from your Profile.

Your personalized missions are ready

We tailored these first steps based on your answers.

    PRISM Welcome Gift

    This is a personal welcome gift from PRISM.

    Congratulations.

    You explored PRISM.

    You earned Apprentice.

    As a welcome gift, unlock Full PRISM Access for the configured trial duration.

    This starts Trial. Trial timer begins only after you activate this gift.

    Welcome to PRISM

    We've prepared a personalized Apprentice Journey based on your goals and experience.

    This journey introduces you to the capabilities of PRISM that are most relevant to you.

    Complete all 8 missions to earn your Apprentice title. 8 MISSIONS

    PRISM Surprise Offer

    Complete your Apprentice Journey to unlock a special gift from PRISM.

    • No payment required
    • No credit card required
    • Just complete the journey
    MISSION CONTROL
    0 / 8 missions complete
    NEXT UP Continue your missions
    View full roadmap →
    Mission Complete 0 / 8 Completed Next: Keep going
    SYSTEM BRIEF

    ⬤ System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        ◈ Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Topic-Wise Progress
        Experience Points 0 XP
        Read subtopics & solve challenges to earn XP
        Theory Read +0 XP
        Solved +0 XP
        Streak Bonus +0 XP
        Theory Read 0%
        — Mastered — Solved
        Weekly Streak 0 day streak
        Mon
        Tue
        Wed
        Thu
        Fri
        Sat
        Sun
        Keep going — log in daily to build your streak!
        0 0%
        Skill Profile
        Recommended Next
        🎯 Your Focus

        You haven't explored enough yet.

        Focus on
        → Understanding System Design
        → Estimating Scale
        Next Action
        Continue → Next: –
        Mock Interview Checklist
        Architecture DNA
        Engineering Profile
        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Engineering Profile

          Company Interview Paths

          Progress Summary