Real World Systems Flashcards

(10 cards)

1
Q

How would you design a URL shortener?

A

Key components: generate short unique IDs (base62 encoding), store mapping in key-value DB, handle redirects with 301/302. Considerations: collision handling, analytics, expiration, custom URLs, rate limiting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you design a news feed (like Twitter/Facebook)?

A

Fan-out on write: precompute feeds and store in cache for fast reads. Pull model for celebrities. Store posts in timeline DB, use Redis for active feeds. Pagination with cursor-based approach.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you design a rate limiter?

A

Algorithms: token bucket (smooth traffic), leaky bucket (fixed rate), fixed/sliding window. Store counters in Redis with TTL. Distributed: centralized vs per-node. Return 429 status when limited.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you design a messaging system (like WhatsApp)?

A

WebSocket for real-time bidirectional communication. Message queue for offline delivery. Store messages in distributed DB partitioned by conversation. End-to-end encryption. Presence service for online status.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you design a video streaming service (like YouTube)?

A

CDN for content delivery, adaptive bitrate streaming, video transcoding pipeline, chunked uploads, separate storage for metadata and videos. Use object storage. Recommendation engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you design a web crawler?

A

URL frontier queue (BFS/DFS), politeness policy (robots.txt, rate limiting), distributed crawling, deduplication (URL fingerprinting), content parsing, storage (document store), periodic recrawling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How would you design an autocomplete system?

A

Trie data structure for prefix matching, cache popular queries, precompute suggestions, rank by frequency/recency. Store in memory for speed. Update asynchronously. Handle typos with fuzzy matching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would you design a distributed cache?

A

Consistent hashing for data distribution, replication for availability, eviction policies (LRU), cache invalidation strategy. Handle node failures gracefully. Consider Redis Cluster or Memcached.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How would you design a notification system?

A

Push notifications (FCM/APNs), email (SES/SendGrid), SMS (Twilio). Message queue for reliability, rate limiting, user preferences, retry logic, deduplication. Track delivery status.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How would you design a file storage system (like Dropbox)?

A

Block-level deduplication, chunking, metadata store, sync service, conflict resolution, versioning. Use object storage (S3). Delta sync for bandwidth efficiency. Desktop client with local cache.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly