PUBLIC QUESTION PREVIEW
System Design interview questions
HLD, LLD, scalability, design patterns — how to build systems that last.
Showing 12 of 63 source questions. Sample answers are study material, not employer-specific hiring guidance.
How to work through this preview
Attempt each question before reading its answer. For a concept, give a definition and a concrete example. For code, state constraints, walk through a small input, and check complexity. For design, separate requirements from assumptions and explain failure handling. Use real situations for behavioral answers.
QUESTION 1 / medium / system design
How would you design a URL shortener like bit.ly? Walk through the key components.
Sample answer
Hints to guide your next attempt
- How do you generate short codes? How do you handle redirects at scale?
- Think about reads vs. writes ratio
Read the supplied solution walkthrough
1. Clarify Requirements
Functional: create short URL, redirect to original URL, optional analytics (click count, geography). Non-functional: high availability (99.99%), low latency redirects (<10ms), scale to 100M URLs/day created, 10B redirects/day. Read:Write ratio → ~100:1 (read-heavy system). URL lifespan: permanent or expiring?
2. Capacity Estimation
Writes: 100M URLs/day = ~1,160 URLs/sec Reads: 10B redirects/day = ~115,000 redirects/sec Storage: 100M URLs × 500 bytes = 50GB/day. Over 5 years = ~90TB (manageable with object storage). Cache: 80/20 rule — cache top 20% of URLs = ~10GB hot cache needed.
3. High-Level Design
Components: - API servers: POST /shorten → returns short code. GET /{code} → 302 redirect. - Short code generation: Base62(auto-increment ID) or Snowflake ID → 7 chars = 62^7 = 3.5T unique URLs. - Database: shortCode → {originalUrl, userId, createdAt, expiresAt}. Use NoSQL (Cassandra/DynamoDB) for write throughput. - Cache layer: Redis with LRU eviction. Cache popular codes — avoids DB hit on 99% of redirects. - CDN: cache redirects at edge for globally distributed low latency.
4. Deep Dive & Trade-offs
301 vs 302 redirect: - 301 Permanent: browser caches it — no future server hit. Better performance, but can't track clicks. - 302 Temporary: hits server every time — enables analytics. Use 302 if analytics required. Collision prevention: use DB unique constraint on shortCode. On collision, regenerate. Custom URLs: allow users to pick their own short code. Check availability first, store separately. Deletion/expiry: soft delete with expiresAt field. Background job cleans up expired entries. Analytics: async — write click events to a Kafka topic → Flink/Spark processes → analytics DB.
Source tags: system-design / url-shortener / hld / caching
QUESTION 2 / medium / conceptual
What is the CAP theorem? Explain with examples of databases that choose CP vs AP.
Sample answer
Hints to guide your next attempt
- You can only guarantee 2 of 3: Consistency, Availability, Partition Tolerance
- Network partitions are inevitable in distributed systems
Source tags: cap-theorem / consistency / availability / distributed-systems
QUESTION 3 / easy / conceptual
What is the Singleton design pattern? When is it useful and when is it a problem?
Sample answer
Hints to guide your next attempt
- One instance, global access point
- Thread safety issue with lazy initialization
Source tags: singleton / design-pattern / thread-safety / lld
QUESTION 4 / medium / conceptual
What is consistent hashing? Why is it used in distributed systems?
Sample answer
Hints to guide your next attempt
- Minimise data movement when nodes are added or removed
- Hash ring with virtual nodes
Source tags: consistent-hashing / distributed-systems / caching / scalability
QUESTION 5 / medium / system design
How would you design a rate limiter? What algorithms exist?
Sample answer
Hints to guide your next attempt
- Token bucket vs sliding window vs fixed window
- Where to store state — Redis?
Read the supplied solution walkthrough
1. Requirements
Functional: limit requests per user/IP per time window; return 429 when exceeded; configurable limits per API route. Non-functional: low latency (< 2ms overhead), high availability, correct under concurrent load.
2. Algorithm Choice
Token Bucket: tokens replenish at fixed rate; burst allowed up to bucket capacity. Best for most APIs. Sliding Window: accurate, no boundary spikes, but more memory. Fixed Window: simplest but allows 2x burst around boundary.
3. Storage Layer
Redis for distributed counter: INCR + EXPIRE (fixed window), or ZADD + ZCOUNT (sliding window log). Lua script for atomicity: check + increment in one atomic operation.
4. Architecture
Place rate limiter at API Gateway / reverse proxy (Kong, Nginx, AWS API Gateway). Multi-layer: IP-level at gateway, user-level in application middleware. Headers: X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After.
Source tags: rate-limiting / token-bucket / sliding-window / redis / system-design
QUESTION 6 / hard / conceptual
What is CQRS and Event Sourcing? When would you use them together?
Sample answer
Hints to guide your next attempt
- CQRS = separate read and write models
- Event Sourcing = store events, not state
Source tags: cqrs / event-sourcing / architecture / system-design
QUESTION 7 / hard / system design
How would you design a real-time notification system (push, email, SMS)?
Sample answer
Hints to guide your next attempt
- Decouple event production from delivery
- Different channels need different providers
Read the supplied solution walkthrough
1. Requirements
Functional: send push/email/SMS notifications; user preference management; delivery tracking. Non-functional: 99.9% delivery rate, low latency for push (<5s), high throughput (10M notifications/day).
2. Core Design
Notification API → validate & enrich → publish to Kafka (one topic per channel: notifications.push, notifications.email, notifications.sms). Worker consumers pull from Kafka → call provider API → update delivery status in DB.
3. Reliability
Retry with exponential backoff (3 attempts). Dead letter queue after exhaustion. Idempotency key per notification — prevents duplicate sends on retry. At-least-once delivery; idempotent providers handle duplicates.
4. User Preferences & Scale
Preference service: opt-out flags, quiet hours, channel priority. Scale: partition Kafka by userId for per-user ordering. Workers scale horizontally. Rate limiting per provider (SMS carriers throttle). Priority queue for critical alerts.
Source tags: notification-system / kafka / push-notifications / system-design
QUESTION 8 / easy / conceptual
What is the difference between horizontal and vertical scaling? When would you choose each?
Supplied choices
- Horizontal scaling means upgrading hardware; vertical scaling means adding more machines
- Vertical scaling is always preferable as it avoids distributed systems complexity
- Vertical scaling adds resources to one machine; horizontal scaling adds more machines — horizontal requires stateless design and load balancing
- Both produce identical results; the choice is purely cost-based
Source answer choice: C. Vertical scaling adds resources to one machine; horizontal scaling adds more machines — horizontal requires stateless design and load balancing
Sample answer
Hints to guide your next attempt
- Scale up vs scale out
- Stateless services are easy to scale horizontally
Source tags: scaling / horizontal / vertical / load-balancer / system-design
QUESTION 9 / hard / conceptual
What is database sharding? What are the common sharding strategies and their trade-offs?
Sample answer
Hints to guide your next attempt
- Sharding = split data across multiple DBs
- Shard key choice determines everything
Source tags: sharding / database / distributed-systems / scalability
QUESTION 10 / medium / conceptual
What is a message queue? When would you use Kafka vs RabbitMQ?
Sample answer
Hints to guide your next attempt
- Event streaming vs traditional message queue — different guarantees
- Can consumers re-read messages?
Source tags: message-queue / kafka / rabbitmq / event-streaming / system-design
QUESTION 11 / hard / conceptual
What are the key microservices communication patterns? Circuit breaker, saga, API gateway.
Sample answer
Hints to guide your next attempt
- Sync vs async communication
- How do you handle failures in a chain of services?
Source tags: microservices / circuit-breaker / saga / api-gateway / system-design
QUESTION 12 / medium / system design
Explain the PACELC theorem. How does it extend CAP?
Sample answer
Read the supplied solution walkthrough
CAP recap
CAP = Consistency, Availability, Partition tolerance. You can only guarantee 2 of 3 during a network split.
The gap CAP ignores
CAP says nothing about normal (non-partition) operation. PACELC fills this gap.
PACELC formula
If Partition: choose A or C. Else: choose L (low latency) or C (strong consistency). Real systems must pick both tradeoffs.
Examples
DynamoDB = PA/EL. Cassandra = PA/EL. HBase = PC/EC. Spanner = PC/EC (uses TrueTime). MongoDB = PA/EC.
Why it matters
When designing, ask: "what latency vs consistency tradeoff is acceptable in the happy path?" — not just during failures.
Source tags: pacelc / cap / consistency / latency / distributed-systems / system-design
Check understanding, not recognition
- Can you explain the answer without reading it?
- Can you show when the approach fails or needs a different assumption?
- Can you connect the concept to a real project, task, or decision you have made?
- Can you distinguish a simplified interview example from a production requirement?
A LITTLE MORE CLARITY
Frequently asked questions
How many System Design questions are shown here?
This public preview shows 12 questions with the supplied answers from the app's 63-question System Design bank. Full interactive practice requires signing in.
Should I memorize the sample answers?
Use them as reference explanations, not a script or a guarantee of technical correctness for every environment. Explain your assumptions, validate code against your language and version, and discuss trade-offs. Behavioral answers should be built from your own experience.
What do hints and solution steps mean?
Hints identify ideas to consider before reading the answer. When the source question includes steps, they are shown as a separate walkthrough. Example capacities and design targets in a solution are assumptions for that exercise, not real system statistics.
BUILD YOUR NEXT OPPORTUNITY
Practice System Design actively.
Sign in to use the full topic bank and interactive practice workspace.