Designing Large-Scale System Examples

1. Designing URL Shortener System

ComponentDetail
ID generationBase62 of counter (Snowflake) or hash + collision check
StorageK/V (DynamoDB / Redis-persistent); short_code → long_url
Read path302 redirect; cache hot codes
AnalyticsClick events → Kafka → DW
Scale~100K reads/sec; CDN-cacheable redirects
Custom aliasReserve namespace

Example: short code lookup

String longUrl = cache.getOrLoad(code, () -> db.findLongUrl(code).orElseThrow(NotFound::new)); return Response.status(302).location(URI.create(longUrl)).build();

2. Designing Social Media Feed System

ApproachDetail
Fan-out on writePush post to followers' feeds; fast read
Fan-out on readAggregate at read; better for celebs
HybridPush for normal, pull for celebrities
StoragePer-user feed in Redis/Cassandra
RankingML model on candidate set
PaginationCursor by score / time

3. Designing Video Streaming Platform

ComponentDetail
UploadMultipart to S3
TranscodeHLS/DASH ladder via MediaConvert
StorageObject store + CDN
DeliveryHLS over CDN; adaptive bitrate
MetadataDB; search via ES
DRMWidevine / FairPlay / PlayReady
RecommendationCollaborative + content-based ML

4. Designing Ride-Sharing System

ComponentDetail
Driver locationStream to Tile38/Redis (H3 cells)
MatchingGeo query nearest available; ETA + price
Trip state machinerequested → matched → en-route → arrived → in-trip → completed
PricingSurge based on supply/demand per cell
PaymentHold → capture on completion
Map / routingOSRM / vendor

5. Designing E-commerce Platform

Bounded ContextDetail
CatalogProducts, search (ES/Vespa)
CartPer-user; Redis + DB persistence
InventoryReservations; eventually consistent
OrderSaga across cart/inventory/payment
PaymentStripe / Adyen integration
FulfillmentWarehouse / shipping events
RecommendationOnline + offline scoring

6. Designing Chat Application

ComponentDetail
ConnectionWebSocket gateway, sticky LB
BackplaneRedis / NATS for cross-node fan-out
StorageCassandra/DynamoDB partitioned by chat_id
Receiptssent / delivered / read
PushFCM/APNs when offline
E2EOptional Signal protocol
SearchPer-user index in ES

7. Designing Search Engine

ComponentDetail
CrawlerDistributed; respect robots.txt
IndexerInverted index; Map-Reduce / Spark
StorageSharded; per-term posting lists
QueryTokenize → fan-out shards → merge top-K
RankingBM25 + LTR + signals (PageRank, freshness)
Hybrid+ vector search for semantic

8. Designing Rate Limiter Service

ElementDetail
APIcheck(key, cost) → allow/deny + reset
AlgorithmToken bucket via Redis Lua (atomic)
StorageRedis cluster, sharded by key
Local cachePre-allocate slice for low-latency
Multi-tier limitsper-second / minute / day
Failure modeFail-open with sample logging

9. Designing Distributed Cache System

ComponentDetail
ShardingConsistent hashing
ReplicationPrimary + replicas per shard
EvictionLRU / LFU / TTL
ClientSmart client routes by hash
Hot keyLocal cache + jitter
ExamplesMemcached, Redis Cluster, Hazelcast

10. Designing Newsfeed Ranking System

StageDetail
Candidate genFriends, follows, recommended sources
FilterAlready seen, blocked, policy
ScoringML model predicts engagement
Re-rankingDiversity, freshness, business rules
ServingPre-computed + on-demand

11. Designing Notification Platform

ComponentDetail
Ingest APINotification request
Preference + targetingResolve channels per user
TemplatingLocalized renders
Channel adaptersEmail/SMS/push/in-app
Queue per channelRate-limited workers
TrackingWebhooks → status DB
AnalyticsDelivery, open, click rates

12. Designing Ticketing System

ComponentDetail
InventoryPer-event seat map
HoldReserve seat for N min via Redis lock
QueueVirtual waiting room for high-demand drops
CheckoutIdempotent; payment integration
Anti-botCAPTCHA, device fingerprint, rate limit
Resale / transferMarketplace flow
Scale spikePre-scale + queue + CDN-cached static