URL Shortener System Design — Architecture Decision Records
The purpose of this article is to analyze and digest the URL shortener system and practice the ADR. It’s just a practice, not for the real…
URL Shortener System Design — Architecture Decision Records

Introduction
The purpose of this article is to analyze and digest the URL shortener system and practice the ADR. It’s just a practice, not for the real case.
In this article, we will list challenges and focus on the key decisions.
Agenda
- Understanding Requirements (defining scope)
- Challenges, Estimating Scale, and Bottleneck
- System Design Overview
- Technical Stack & Infra
- Workflow
- Architecture Decision Records
Understanding Requirements (defining scope)
Functional requirements
- Shorten a URL (
URL shortening) - Accept a valid long URL and return a shorten URL
- Example:
[https://example.com/article?id=1234](https://example.com/article?id=1234) ⇒[https://tinyurl.com/xYz12](https://tinyurl.com/xYz12) - Redirect to original URL (
URL redirection) - When accessing the short URL, redirect to the original long URL
- Prevent duplicated short URLs
- If the same long URL is submitted, return the same short URL or handle according to configuration (unless
custom aliasis used) - User authentication
- Allow users to register/login to manage URLs, view analytics, and set expiration
Non-functional requirements
- High
availability(HA) - system must be available
24/7with99.9%uptime - Low
latency URL redirectionshould occur inmillisecondsshortening URLsshould benear-instantaneousScalability- system must handle millions or billions of URLs, supporting high read volume (
URL redirection) and moderate write volume (URL shortening) Reliability- ensure
data persistence - no data loss even during failures (replication, write acknowledgment / quorum)
- use
durable storageandbackups
Unique URL Generation Strategies
- Random string generation: create a fixed-length string from random characters
- unpredictable, no obvious pattern
- risk of collisions, requires collision handling
- okay for unpredictability, but adds complexity
- UUID (Universally Unique Identifier): 128-bit globally identifier
- guarantees uniqueness, no central coordination
- very long, not user-friendly
- not ideal for
TinyURLdue to length - Hashing with
salt: hashes the original URL (e.g.,SHA-256+salt) - unique, secure, hard to reverse
- may not be short, collision possible, needs
mapping storage - useful for security-focused cases, but not optimal for shortening
Base62encoding: converts incrementingIDtoBase62(0-9,a-z,A-Z)- short, compact, deterministic, easy to implement
- needs counter management to avoid
collisions recommendedforTinyURL(fast)
Challenges, Estimating Scale, and Bottleneck
Estimating Scale
- Estimated user traffic
Daily active users (DAU): 10 millionMonthly active users (MAU): 300 millionNew Short URLs/day: 100000 (1% ofDAU)Redirect requests/day: 50 million (5 per user)- Memory requirement (hot URL cache)
- cache top
1Mmost accessed URLs - each mapping: 500 bytes
- total memory: 500 MB
- Network bandwidth (
URL redirection) - 50M redirects/day * 700 bytes = 35 GB/day
avg throughput: 0.4 MB/secpeak throughput: 5 MB/sec
Data Size & Storage needs
- Storage requirement (URL mapping DB)
- 100K new URLs/day * 400 bytes = 50 MB/day
Yearly data= 18GB + overhead- Round up to
50GB/year(with indexes, logs, backups)
Challenges and Bottlenecks
- High
readvolume - focus on
cacheand fastDB reads Writethroughput is moderate- unique URL generation:
base62+zookeper - prevent duplications:
single-key atomic conditional write - durability: write acknowledgment / quorum
Latencysensitivity in redirects- low
latencyinfra needed - Plan for
burst trafficwithautoscaling&CDN support
System Design Overview
CAP Trade-off
According to the non-functional requirements, we may have to choose AP in this application.
For most operations, users can afford eventually consistency between different nodes. Also, the low latency means we may have to give up the consistency.
However, the consistency is important for custom alias operations (this feature is not in our case). For this operation, they should be CP. CP will avoid conflicts.

Components Diagram
There are a few important components in the following diagram.
URL Generation service(URL Shorten service)- contain logic for
key generation,duplicate checking,alias validation Redirection service- high performance resolver for short keys ⇒ long URLs
User management service- handle user authentications

Technical Stack & Infra
Collision Handling in Distributed URL generation — Zookeeper
- Why
collisionshappens? - Multiple services generating IDs independently ⇒ risks of duplications
- No global configurations ⇒
Base62encoding same ID ⇒ incorrectURL mapping - What is
[Zookeeper](https://zookeeper.apache.org/)? - Distributed coordinate service by
Apache - Ensure synchronization across nodes in distributed system
Zookeeperas a solutionautomatic ID generationusingZookeeper-managedglobal counter- guarantees each instances gets a unique ID
- use
znodesto store and manage counters - supports distributed locking to serialize ID generation
- Flow
- service requests
next IDfromZookeeper Zookeeperincrementsglobal counteratomically- ID is
Base62encoded and used asTinyURL- mapping stored in DB (optional)
API Gateway
- Request routing
- Authentication (verify
JWTlocally), authorization - Rate limiting =>
throttling
Authentication
- Implement
OAuth 2.0withJWT tokenfor secure,stateless auth
Storage & Database
Relational DB(e.g.,PostgreSQLwithincremental IDs)usersNoSQL DB(e.g.,DynamoDBforscalibility)mappings(short URL->original URL),metadata(owner_id,created_at)
Cache
RedisorMemcahcedfor high-speedlookup
Infra
horizontal scalingforURL generationservices (scalability&performance)load balancerto distribute traffic across service instances (highavailability)- failover-ready infrastructure using cloud-managed DBs or services (high
availability) replicationin DB to avoidsingle point of failure(highscalability, highavailability)
Workflow
The following sequence diagram shows how components work together.

1. URL Generation
Client application- User submits
long URLto theAPI Gateway API Gateway- Verifies
JWTlocally - Send the request to the
URL Generation service URL Generation service- Check if the generated
TinyURLis existing, if so, return the result with the generatedTinyURL - Request a unique ID from
Zookeeper(ensure no collisions) - Encodes it (e.g.,
Base62) to create theshort URL- Stores themappingto DB andRediscache (long URL→short URL) => write-through strategy - Return the result with the generated
TinyURL
2. Redirection Flow
Client application- User hits
short URL - The request will be sent to the
API Gateway API Gateway- Forwards to the
Redirection service Redirection service- Checks
cachefor theshort URL(fast path) - If not found, queries the DB (cold path)
- Redirect user to the original
long URL
Architecture Decision Records
ADR 1. URL Generation and Redirection Share a Single Mapping Store
In our scenario, the DynamoDB is used by the URL Generation service and the Redirection service. It violates the database-per-service principle of the microservice architecture.
The reason is the latency sensitivity in redirects. It will add the additional latency to the redirction operation.
ADR 2. Cross-Database Short-Code Ownership via DynamoDB owner_id and GSI
In this project, we use the polyglot persistence strategy for databases.
mappings(short URL->original URL),metadata(owner_id,created_at) => useDynamoDB(high capacity, high frequency, key-value, eventually consistency)users=> usePostgreSQL(low capacity, relational-query, strong consistency)
Because tables are in different database, we need a solution to list short URLs for an user and find the owner of the short URL. Our solution has 2 items.
- Add a field
owner_idin themetadatatable (DynamoDB), the field points to theuser_idof theuserstable (PostgreSQL) - Create
global secondary index (GSI)and specify theowner_idfield as thealternative primary key
def list_urls_by_user(user_id):
return dynamodb.query(
IndexName="owner_id-index",
KeyConditionExpression="owner_id = :uid",
ExpressionAttributeValues={":uid": user_id}
)
Reference
Summary
Thanks for your patient. I am Sean. I work as a software engineer.
This article is my note. Please feel free to give me advice if any mistakes. I am looking forward to your feedback.
- The Daily Learning website
메타데이터
- post_id
- 814a6a069de4
- slug
- url-shortener-system-design-architecture-decision-records-814a6a069de4
- url
- https://medium.com/a-layman/url-shortener-system-design-architecture-decision-records-814a6a069de4
- canonical_url
- https://medium.com/a-layman/url-shortener-system-design-architecture-decision-records-814a6a069de4
- author_url
- https://medium.com/@seanhsieh_63050
- status
- ok
- fetched_at
- 2026-07-09 01:30:37