0% found this document useful (0 votes)
20 views4 pages

System Design Qa

The document outlines a 7-step framework for designing various systems, including a URL shortening service, social media platform, chat app, web crawler, video streaming service, e-commerce platform, ride-sharing service, notification system, key-value store, and logging & monitoring system. Each design includes steps for clarifying requirements, capacity estimation, high-level design, database design, API design, key components, and considerations for scalability and reliability. This structured approach helps in systematically addressing the complexities of system design.

Uploaded by

laiba.saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

System Design Qa

The document outlines a 7-step framework for designing various systems, including a URL shortening service, social media platform, chat app, web crawler, video streaming service, e-commerce platform, ride-sharing service, notification system, key-value store, and logging & monitoring system. Each design includes steps for clarifying requirements, capacity estimation, high-level design, database design, API design, key components, and considerations for scalability and reliability. This structured approach helps in systematically addressing the complexities of system design.

Uploaded by

laiba.saleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

System Design Interview: Answers Using 7-Step Framework

1. Design a URL Shortening Service (e.g., TinyURL)


Step 1: Clarify Requirements - Shorten long URLs - Redirect short URLs to original - Optional: URL
expiry, click analytics

Step 2: Capacity Estimation - 100M redirects/day, 10M new URLs/day - ~500 bytes per record → ~5GB/
day, scale to 1B+ URLs

Step 3: High-Level Design - Load Balancer → App Servers → DB (with Cache)

Step 4: Database Design - Table: short_url , long_url , created_at , expiry_time - Index on


short_url

Step 5: API Design - POST /shorten with long URL → returns short URL - GET /<short> →
redirect to long URL

Step 6: Key Components - ID generation with Base62 or Hash - Redis for caching - Async analytics
tracking

Step 7: Scalability & Reliability - DB sharding, cache fallback, rate limiting - Monitor traffic, retries for
failures

2. Design a Social Media Platform (e.g., Twitter/Instagram)


Step 1: Clarify Requirements - Post content, follow users, timelines, like/comment - Media support
(images/videos)

Step 2: Capacity Estimation - 1B users, 100M daily posts - 10TB media storage/month

Step 3: High-Level Design - App Servers → Feed Service, Media Service, DB, Cache - CDN for media

Step 4: Database Design - Users, Posts, Follows, Likes tables - Media metadata in DB, actual media in
Object Store

Step 5: API Design - POST /post , GET /timeline , POST /follow , etc.

Step 6: Key Components - Fan-out on write vs read for feeds - Feed caching - Media upload via CDN

Step 7: Scalability & Reliability - Async feed generation, content moderation tools - Partitioned
timelines, rate limiting

1
3. Design a Chat App (e.g., WhatsApp/Slack)
Step 1: Clarify Requirements - Real-time messaging, group chat, file sharing, notifications

Step 2: Capacity Estimation - 500M users, 100B messages/month

Step 3: High-Level Design - Load Balancer → App + Messaging Servers - WebSocket connection for
real-time - DB and Cache

Step 4: Database Design - Users, Messages, Conversations, Attachments - Use Cassandra or similar
NoSQL for scale

Step 5: API Design - POST /send , GET /messages , POST /group

Step 6: Key Components - WebSocket server for real-time - Message queue for delivery reliability -
Push notification service

Step 7: Scalability & Reliability - Partition chats by user ID - Use delivery ack + retry

4. Design a Web Crawler


Step 1: Clarify Requirements - Crawl and index web pages, respect robots.txt, deduplication

Step 2: Capacity Estimation - Billions of pages, petabytes of data

Step 3: High-Level Design - URL Frontier → Fetcher → Parser → Indexer → Storage

Step 4: Database Design - URLs table, Metadata table, Raw HTML store

Step 5: API Design - Internal APIs: enqueueURL , fetchContent , storeMetadata

Step 6: Key Components - Scheduler for prioritizing crawling - Duplicate checker - Distributed storage

Step 7: Scalability & Reliability - Use Bloom filters for deduplication - Distribute crawler agents

5. Design a Video Streaming Service (e.g., YouTube/Netflix)


Step 1: Clarify Requirements - Upload, stream videos, track views, subscriptions

Step 2: Capacity Estimation - Millions of videos/day, 10PB storage/month

Step 3: High-Level Design - Load Balancer → App Servers - Video Processor → CDN - DB for metadata

Step 4: Database Design - Tables: Users, Videos, Views, Comments, Likes - Media in Object Storage

Step 5: API Design - POST /upload , GET /stream , GET /video-metadata

2
Step 6: Key Components - Transcoder for multiple bitrates - CDN edge nodes for delivery

Step 7: Scalability & Reliability - Async processing, chunked storage - Replication and monitoring

6. Design an E-commerce Platform (e.g., Amazon)


Step 1: Clarify Requirements - User accounts, product catalog, cart, orders, payments

Step 2: Capacity Estimation - 100M users, 1M daily orders

Step 3: High-Level Design - Services: Product, Order, Cart, Payment - DB, Cache, Search Index

Step 4: Database Design - Tables: Users, Products, Orders, Cart, Inventory

Step 5: API Design - POST /order , GET /product , POST /cart/add

Step 6: Key Components - Inventory reservation logic - Recommendation engine - Payment gateway
integration

Step 7: Scalability & Reliability - Use Event Sourcing for orders - Partition inventory, use search engine
(Elasticsearch)

7. Design a Ride-Sharing Service (e.g., Uber)


Step 1: Clarify Requirements - Book rides, match drivers/riders, live tracking

Step 2: Capacity Estimation - 10M daily rides, real-time location updates

Step 3: High-Level Design - Rider App ↔ Dispatcher ↔ Driver App - Location Service + DB

Step 4: Database Design - Tables: Users, Rides, Drivers, Locations

Step 5: API Design - POST /book , GET /location , POST /ride/start

Step 6: Key Components - GPS data stream - Matching algorithm (geohash, radius search) - Map
integration

Step 7: Scalability & Reliability - Kafka for GPS stream - Redis for driver availability - Real-time
WebSocket updates

8. Design a Notification System


Step 1: Clarify Requirements - Send email, SMS, push notifications, retry failures

Step 2: Capacity Estimation - 1B/day notifications

3
Step 3: High-Level Design - Producer → Queue → Notification Worker → External API

Step 4: Database Design - Tables: Notification, User Preferences, Status Logs

Step 5: API Design - POST /notify , GET /status/<id>

Step 6: Key Components - Queue system (Kafka, RabbitMQ) - Retry scheduler - Rate limiter

Step 7: Scalability & Reliability - Multi-channel support - Dead letter queues - Monitoring and alerting

9. Design a Key-Value Store (e.g., Redis)


Step 1: Clarify Requirements - Get, set, delete, expiry

Step 2: Capacity Estimation - 100M ops/sec

Step 3: High-Level Design - Client → API → Storage Engine (In-memory)

Step 4: Database Design - In-memory hashmap with persistence

Step 5: API Design - SET key value , GET key , DEL key , EXPIRE key etc.

Step 6: Key Components - Eviction policies (LRU, TTL) - Persistence (AOF/RDB) - Replication support

Step 7: Scalability & Reliability - Sharding, sentinel for HA - Backups and failover

10. Design a Scalable Logging & Monitoring System


Step 1: Clarify Requirements - Collect logs/metrics, store/query logs, alerting

Step 2: Capacity Estimation - 1TB/day of logs

Step 3: High-Level Design - Client SDK → Collector → Queue → Storage + Alerting Engine

Step 4: Database Design - Time-series DB or Log DB (e.g., Elasticsearch, InfluxDB)

Step 5: API Design - POST /log , GET /query , GET /alerts

Step 6: Key Components - Aggregator - Stream processor (Flink/Kafka) - Alert engine

Step 7: Scalability & Reliability - Indexing logs, tiered storage - Real-time stream processing - Alert on
thresholds

You might also like