backend system design
Salesforce
Google
Amazon

Salesforce System Design: Scalable URL Shortening Service

Topics:
URL Shortener
Key-Value Stores
Caching
Roles:
Software Engineer
Backend Engineer
SDE
Experience:
Mid Level
Senior
Staff

Question Description

You are asked to design a highly available, low-latency URL shortening service (like Bitly) that converts long URLs into compact short aliases and redirects users reliably.

Core problem: accept a long URL via API, generate a globally unique 6–8 character alias, store the mapping, and redirect short links to original URLs with <100ms latency under heavy load (millions of writes, billions of reads/day). Support idempotency (same long URL → same short URL), optional custom aliases, TTL/expiration, and basic access analytics.

Interview flow: start by clarifying scale, SLAs and feature priorities; propose APIs (CreateShortURL, Redirect, GetStats); sketch a high-level architecture (load balancers, stateless app servers, cache layer, persistent key-value store, message queue for analytics); design short-code generation (base62 of sequential ID / Snowflake / hash+collision-check) and an idempotency strategy (lookup by long URL or deterministic hashing with collision resolution). Discuss scaling: sharding, consistent hashing, cache pop/expiration (Redis/Cloud CDN), replication for durability (Cassandra/DynamoDB or RDBMS with strong backups), and background jobs for TTL cleanup and analytics aggregation.

Skill signals: distributed systems, capacity planning, key-value data modeling, caching strategies, consistency vs latency trade-offs, failure modes, and monitoring/operational readiness. Be prepared to justify trade-offs and handle follow-ups about collisions, hot keys, and analytics throughput.

Common Follow-up Questions

  • How would you ensure global uniqueness and avoid collisions if you use hashing for short-code generation? Describe collision detection and resolution.
  • Design the analytics pipeline to track billions of redirects per day. How do you collect, aggregate, and serve access counts with minimal impact on redirection latency?
  • How would you handle hot keys (very popular short URLs) and protect the system from read/write storms while keeping <100ms latency?
  • Explain a strategy to support custom aliases and enforce idempotency when many users request the same long URL concurrently.

Related Questions

1Design a URL redirection service using a CDN — how does it differ from an app-level redirect?
2System design: Build a highly available key-value store for fast lookups and long-term durability
3Design a rate limiter for the URL creation API to prevent abuse and ensure fairness
4Design a short-lived signed URL system with expiration and secure access controls

Explore More Questions

Practice This Question with AI

Get real-time hints, detailed requirements, and insightful analysis of the question.

Scalable URL Shortener Design - Salesforce Backend Guide | Voker