System Design Interview Questions and Answers: 60 Questions from Easy to Hard
This guide is for software engineers in India preparing for system design rounds: SDE-1 and SDE-2 candidates at product companies and startups, and senior or lead engineers moving into design-heavy roles at IT services firms. It has 60 questions with model answers in three levels: the building blocks every fresher should explain, the standard designs asked at one to three years (URL shortener, feed, chat, notifications, parking lot), and senior questions on payment correctness, consistency trade-offs, multi-region setups and capacity planning. Every estimate was recalculated and every code snippet was run. For database theory see our DBMS guide, and for cloud services our AWS guide. Answer each question aloud with a quick sketch, compare, then take the System Design mock test.
- 60 questions, 3 levels
- Updated
- CoreHRx Jobs
What system design interviews cover
- A high-level design round, often 45 to 60 minutes, where you design a known product such as a URL shortener, chat app, food delivery or ticket booking system end to end.
- Back-of-the-envelope estimates: requests per second from daily users, storage per year, bandwidth and cache size, used to justify each choice.
- Building blocks and their trade-offs: load balancers, caches, SQL and NoSQL databases, replication, sharding, queues, CDNs and rate limiters.
- At many Indian product companies, a separate low-level design or machine coding round: classes, interfaces, design patterns and working code for something like a parking lot or a booking system.
- For senior roles, failure handling, consistency, cost and how you lead the discussion, including questions about systems you built or reviewed.
How freshers should prepare
- Learn each building block through one concrete use: why a cache helps a job listing page, why a queue helps an SMS sender, why a CDN helps images.
- Practise the arithmetic until it is quick: 86,400 seconds in a day, one million requests a day is about 12 a second, and the steps from KB to MB, GB and TB.
- Design three or four classic systems on paper in a fixed order: requirements, estimates, APIs, data model, diagram, then one deep dive.
- For LLD rounds, write small object-oriented programs in your main language and practise explaining why each class exists.
How experienced candidates should prepare
- Prepare two systems you actually built: the scale, the architecture, one decision you would change today and why.
- Go deep on the correctness topics that separate senior candidates: idempotency, delivery guarantees, consistency models, outbox and sagas, and how locks fail.
- Practise driving the interview: state your assumptions, offer two options with their trade-offs, and choose one instead of waiting for hints.
- Know the real numbers from your own systems, such as peak-to-average traffic, cache hit rate and replica lag, and share only what your employer allows.
Low-level design and machine coding rounds
- Clarify scope before coding: which entities, which operations, and what must be easy to extend later, such as new vehicle types or pricing rules.
- Use interfaces and composition for the parts that change, and patterns such as Strategy, State, Observer and Factory only where they remove real duplication.
- Keep the code runnable with a small driver or tests, handle concurrency for shared resources such as seats or parking spots, and name classes after the domain.
- Expect a requirement change midway; a design that absorbs the new rule with a new class instead of edits everywhere scores well.
Common mistakes to avoid
- Drawing boxes before agreeing on requirements and scale, and then solving a problem the interviewer did not ask.
- Naming technologies without reasons. Say why Kafka, Redis or Cassandra fits this access pattern, and what it costs.
- Skipping failure cases: what happens when the cache, a replica, the payment partner or a whole zone goes down.
- Claiming exactly-once delivery or perfect consistency for free. Strong candidates state the guarantee they really give and how duplicates are handled.
- Spending half the time on one component and never reaching bottlenecks, monitoring and trade-offs.
System Design interview questions: Easy questions (freshers)
20 questions1. What steps do you follow in a system design round?
I use a fixed order so I do not get lost. First, clarify requirements: what the system must do, who uses it, and the scale, such as daily users and the read-to-write ratio. Second, a quick estimate of traffic and storage. Third, define the main APIs and the data model. Fourth, draw the high-level design: clients, load balancer, services, databases, caches and queues. Fifth, go deep on the one or two parts the interviewer cares about most, such as the feed or the payment step. Last, cover failures, bottlenecks and trade-offs. Interviewers check that you lead the discussion instead of jumping straight to boxes and technology names.
2. What is the difference between high-level design and low-level design?
High-level design shows the big building blocks and how they talk to each other: services, databases, caches, queues, CDNs and the path of a request, with each choice justified by scale and reliability. Low-level design zooms into one service: classes and interfaces, their relationships, database tables and columns, method signatures and design patterns. For a movie ticket app, the HLD decides that seat booking runs as its own service with a relational database and a cache for show listings, while the LLD defines Show, Screen, Seat and Booking classes and how a seat hold works. Many Indian product companies run these as separate rounds, and LLD rounds often expect working code.
3. What are functional and non-functional requirements? Give both for a food delivery app.
Functional requirements say what the system does: customers search restaurants near them, see menus, place and pay for an order and track the delivery partner live; restaurants accept or reject orders; partners get assigned trips. Non-functional requirements say how well it must work: menu pages load quickly even at dinner peak, ordering stays available during a cricket final, payments are never charged twice, location updates arrive within a few seconds, and the system can grow city by city. Write both down in the first few minutes and agree on what is out of scope, such as ratings or offers. Many candidates list only features and forget the qualities that actually drive the design.
4. A service has 10 million daily active users who each make about 20 requests a day. What are the average and peak requests per second?
Requests per day are 10 million times 20, which is 200 million. A day has 86,400 seconds, so the average is about 2,315 requests per second. Traffic is never flat: food and shopping apps peak around lunch and dinner, so I would assume a peak of about three times the average, roughly 6,900 requests per second, and say that assumption aloud. A shortcut worth remembering is that one million requests a day is about 12 per second. Interviewers do not want exact figures; they want to see whether you need one server, ten or a thousand, and whether you planned for the peak instead of the average.
5. A photo feature gets 1 million uploads a day, each about 200 KB. How much storage does it need per year?
One million uploads of 200 KB each is 200 GB a day, taking 1 KB as 1,000 bytes. Over 365 days that is 73 TB of new data a year. Storage systems keep several copies for durability, so with three replicas the raw disk is about 219 TB a year, although managed object storage handles the copies for you and usually bills for the 73 TB you store. I would also add resized versions, such as a thumbnail and a medium size, which add a little more per photo. The upload rate is small, about 12 per second on average, so the real challenge is storage growth and serving reads, not handling writes.
6. What is the difference between vertical and horizontal scaling?
Vertical scaling means a bigger machine: more CPU, more RAM or faster disks for the same server. It is simple, needs no code change and often suits a database early on, but it has a ceiling, the largest machines cost much more, and that one machine is still a single point of failure. Horizontal scaling means adding more machines behind a load balancer. It has no hard ceiling and survives the loss of one server, but the application must be stateless and data must be shared or split. A typical Indian startup runs its API on several small instances and scales its MySQL primary vertically until it really needs to shard.
7. What does a load balancer do, and how do round robin, least connections and IP hash differ?
A load balancer sits in front of a group of servers, spreads incoming requests across them, stops sending traffic to servers that fail health checks, and lets you add or remove servers without clients noticing. Round robin sends requests to each server in turn; nginx uses weighted round robin by default, so a bigger server can be given a larger share. Least connections sends the next request to the server with the fewest active connections, which helps when some requests are slow, such as report downloads. IP hash sends a client to the same server every time, which gives sticky sessions but uneven load when many users share one office IP address.
8. What does it mean for a web server to be stateless, and where do sessions go then?
A stateless server keeps nothing about a user between requests in its own memory or disk, so any server can handle any request. That is what lets a load balancer send the next request anywhere and lets you add or remove servers freely. The state still exists, it just moves out of the app server. Login sessions go to a shared store such as Redis or into a signed token the client sends with each request, uploaded files go to object storage, and carts go to a database or cache. If sessions live in one server's memory, users get logged out whenever that server restarts or the load balancer moves them elsewhere.
9. What is cache-aside, and how does a read flow through it?
In cache-aside, also called lazy loading, the application talks to both the cache and the database. On a read it first checks the cache, for example Redis with the key job:4521. On a hit it returns the value at once. On a miss it reads the row from the database, writes it into the cache with a TTL, and then returns it. On an update it writes to the database and deletes the cache key, so the next read loads fresh data. It is simple, and the cache holds only data that people actually ask for. The costs are that the first read after a miss is slow and data can be stale until the key is deleted or expires.
10. When a cache is full, what decides which keys go? Compare TTL expiry with LRU and LFU eviction.
Expiry and eviction are different things. A TTL removes a key when its time is up, whatever the memory situation; you use it to limit staleness, say 60 seconds for a product price. Eviction happens only when the cache reaches its memory limit and must make room. LRU removes the keys used least recently; LFU removes those used least often, which protects keys that stay popular from being pushed out by a one-off scan. In Redis you choose this with the maxmemory-policy setting, with options such as allkeys-lru and allkeys-lfu. Its default, noeviction, returns errors on writes instead of evicting, so set the policy on purpose for a cache.
11. How is replication different from sharding, and when do you need each?
Replication keeps full copies of the same data on several machines. It adds read capacity and survives a machine failure, but every copy still holds all the data, and usually only the primary accepts writes. Sharding, also called horizontal partitioning, splits the data so each machine holds only a part, for example users with IDs in one range on shard 1 and the next range on shard 2. It spreads both storage and write load, but queries across shards and joins become harder. Large systems use both, because each shard is itself replicated. A common mistake is to suggest sharding for a read-heavy problem that replicas and a cache would solve.
12. Why would you put a message queue between an order service and the SMS sender?
Without a queue, the order API calls the SMS provider directly, so a slow or failing provider makes checkout slow or makes it fail, and a sale-day spike hits the provider all at once. With a queue, the order service saves the order, publishes an order-placed message and replies to the customer immediately. A separate worker reads the messages and sends SMS at a rate the provider accepts, retrying failures. The two sides are decoupled: each can be deployed, scaled or paused on its own, and messages wait safely during a provider outage. The trade-off is that sending is now asynchronous, so the SMS may arrive a few seconds later.
13. What does a CDN cache, and what should you never cache at the edge?
A CDN is a network of edge servers in many locations that keep copies of content close to users, so a user in Guwahati is served from a nearby edge instead of your origin servers in Mumbai. It suits static and shared content: images, JavaScript and CSS bundles, fonts, video segments, downloadable brochures and public pages that look the same for everyone. The origin controls caching with Cache-Control headers, for example a long max-age for files whose names contain a version hash. Never cache personalised or private responses at the edge, such as a logged-in user's profile, cart or salary slip, unless the response is marked private or the cache key includes the user.
14. Where would you store users' profile photos and resumes, and what goes into the database?
The files go to object storage such as Amazon S3 or Google Cloud Storage, not into database BLOB columns and not on an app server's local disk. The database keeps only metadata: the object key, owner ID, file type, size, upload time and a virus-scan status. Object storage is cheap, durable and grows without you managing disks, and the app servers stay stateless. Public profile photos can be served through a CDN. Resumes contain personal data, so that bucket stays private and the app hands out short-lived signed links only after checking that the viewer may see that file. Storing files on one server breaks the moment you add a second server.
15. How would you design REST endpoints for jobs and applications on a job portal?
Model resources as nouns and let the HTTP method carry the action. GET /jobs?city=pune&page=2 lists jobs with filters, GET /jobs/{id} returns one job, POST /jobs creates a posting, PATCH /jobs/{id} edits some fields and DELETE /jobs/{id} closes it. Applications are a sub-resource: POST /jobs/{id}/applications to apply, and GET /candidates/me/applications for a candidate's own list. Return clear status codes: 201 when created, 400 for bad input, 401 when not logged in, 403 when logged in but not allowed, 404 when missing and 409 for a duplicate application. Verbs in URLs, such as /getJobs, are a common mistake that interviewers notice.
16. What does idempotent mean, and which HTTP methods are idempotent?
An operation is idempotent if doing it twice has the same effect on the server as doing it once. RFC 9110 defines PUT, DELETE and the safe methods, GET, HEAD, OPTIONS and TRACE, as idempotent, while POST is not, and RFC 5789 says PATCH is neither safe nor idempotent. Sending PUT /users/42/email twice with the same body leaves the same email; deleting an item that is already gone changes nothing more, even if the second reply is 404. Sending POST /payments twice could charge twice. This matters because networks fail: a client that got no response can safely retry an idempotent request, while a POST needs an idempotency key first.
17. What is rate limiting, and what should an API return when a client goes over the limit?
Rate limiting caps how many requests a client can make in a time window, for example 100 searches a minute per user or 5 OTP requests an hour per phone number. It protects servers from overload and abuse, stops one noisy client from hurting others, and controls costs such as SMS charges. When a client goes over the limit, reject the request with HTTP 429 Too Many Requests, defined in RFC 6585, ideally with a Retry-After header saying how long to wait. A well-behaved client backs off when it sees 429. Note that nginx's limit_req module returns 503 by default, so set limit_req_status to 429 so clients can tell limiting apart from an outage.
18. What is the difference between latency and throughput, and why do teams track p99 instead of the average?
Latency is how long one request takes, for example 120 ms for a search. Throughput is how many requests the system completes per second. They are related but different: a system can serve 10,000 requests a second while some users still wait two seconds. Averages hide this, because a few very slow requests barely move the mean. Percentiles show it: a p99 of 800 ms means 1 percent of requests take longer than 800 ms. A page that makes 20 backend calls has about an 18 percent chance that at least one of them is slower than the p99, so tail latency is what users feel. Always say which percentile and time window you mean.
19. What is a single point of failure? Find the ones in a setup with one load balancer, two app servers and one database.
A single point of failure is any component whose failure takes the whole service down. The two app servers are fine as long as one can carry the full traffic when the other dies. The single load balancer is a SPOF: run a pair with a floating IP, or use a managed cloud load balancer that is redundant by design. The single database is the bigger risk: add a standby replica with automatic failover, and take backups that you actually test by restoring. Then look for hidden ones: one Redis node holding sessions, one NAT gateway, a cron job that runs on one server, or one engineer who alone knows how to deploy.
20. What do RTO and RPO mean? Give an example for a payroll system.
RPO, the recovery point objective, is how much data you can afford to lose, measured in time: an RPO of 5 minutes means that after a disaster you may lose at most the last 5 minutes of writes. RTO, the recovery time objective, is how long the service may stay down before it is working again. For a payroll system, losing approved salary changes is serious, so I would aim for an RPO of a few minutes using continuous replication or frequent log backups, while an RTO of one or two hours may be acceptable outside the monthly payroll run. Tighter targets cost more: a near-zero RPO needs synchronous copies, which add latency to every write.
Ready to check yourself? Take the free System Design mock test
System Design interview questions: Medium questions (1-3 years)
20 questions21. How do you generate unique 7-character short codes for a URL shortener, and how many codes does base62 give?
Base62 uses 0 to 9, a to z and A to Z, so 7 characters give 62 to the power 7, about 3.52 trillion codes, and 6 characters about 56.8 billion. One option is to hash the long URL and keep 7 characters, which needs a collision check and a retry. The cleaner option is to take a unique number from a counter and encode it in base62, which never collides; the snippet turns one billion into 15FTGg. So that one counter does not become a bottleneck, each app server leases a block of, say, a million numbers at a time. Sequential codes are guessable, so scramble the number with a reversible mapping first if links must not be enumerable.
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def base62(n):
s = ""
while n:
n, r = divmod(n, 62)
s = ALPHABET[r] + s
return s or "0"
print(base62(125), base62(1_000_000_000), base62(62**7 - 1))
# 21 15FTGg ZZZZZZZ22. Estimate storage, read traffic and cache memory for a URL shortener with 100 million new links a month and 100 reads for every write.
New links: 100 million a month divided by 30 days of 86,400 seconds is about 38.6 writes per second. Reads at 100 times that are about 3,860 per second, more at peak. Over 5 years that is 6 billion links; at about 500 bytes per row, storage is about 3 TB, easy for a partitioned database. Reads come to about 333 million a day, and caching 20 percent of them at 500 bytes each gives 33 GB. That is only an upper bound, because popular links repeat: size the cache by distinct links read in a day, so 10 million distinct hot links need about 5 GB. And 6 billion links use under 0.2 percent of the 7-character base62 space.
23. You are designing the home feed for a social app. Would you use fan-out on write or fan-out on read?
With fan-out on write, when a user posts, the system pushes the post ID into a precomputed feed list for every follower, for example a Redis list per user. Reading the feed is then a fast single lookup, which suits most users, who follow a few hundred accounts. The problem is a celebrity with 10 million followers, where one post means 10 million writes. With fan-out on read, the feed is built when the user opens the app by pulling recent posts from everyone they follow and merging them, which is cheap to write but slow to read. Most real systems use a hybrid: push for normal accounts, pull celebrity posts at read time, then merge and rank.
24. Design one-to-one chat like WhatsApp. How does a message reach an online user and an offline user?
Each online client keeps a persistent WebSocket connection to a chat gateway server, and a presence store such as Redis records which gateway holds each user's connection. When Asha sends a message to Ravi, her gateway passes it to a chat service, which gives it a sequence number within the conversation and stores it durably, for example in a wide-column store keyed by conversation ID. Then it looks up Ravi's gateway and pushes the message, and Ravi's app replies with a delivered receipt. If Ravi is offline, the message waits in storage and a push notification goes out; when he reconnects, his app fetches everything after the last sequence number it has.
25. Design a notification service that sends OTP SMS, order emails and push alerts for an e-commerce app.
Other services call one notification API with the user, event type and data, never the providers directly. The service checks user preferences and quiet hours, renders a template, and puts the job on a separate queue per channel and priority, so a flood of marketing emails never delays an OTP. Workers per channel call the SMS gateway, the email provider, or push services such as Firebase Cloud Messaging and APNs, with retries, backoff and a second provider for OTPs. A message ID, status log and dedupe key give tracking and stop duplicates. In India, commercial SMS, OTPs included, falls under TRAI regulations, so confirm with both SMS providers how sender IDs and templates must be set up before launch.
26. Compare write-through, write-back and write-around caching. Which would you use for a product price?
Write-through writes to the cache and the database together on every update, so the cache is always fresh, but every write pays both costs and you may cache data nobody reads. Write-back writes only to the cache and flushes to the database later in batches, which makes writes very fast but loses data if the cache node dies before flushing. Write-around writes only to the database and lets the cache fill on the next read miss, which keeps write-once data out of the cache. For a product price, a wrong value means real money, so I would write to the database and then delete the cache key, or use write-through, and never write-back.
27. During an IPL match, the live-score cache key expires and 50,000 requests hit the database at once. What happened, and how do you prevent it?
This is a cache stampede, also called a thundering herd. A very hot key expired, and every request that missed the cache went to the database at the same moment to rebuild the same value. The fixes are usually combined. Request coalescing lets only one request per key rebuild it, using a short lock in Redis, while the others wait briefly or get the old value. Serving slightly stale data while one worker refreshes in the background works too; HTTP caches express this with stale-while-revalidate from RFC 5861. Refresh very hot keys before they expire, and add random jitter to TTLs so thousands of keys do not expire in the same second.
28. A user sees a new comment, refreshes, and it disappears, then comes back on the next refresh. Reads go to three MySQL replicas. Why, and how do you fix it?
Each refresh went to a different replica, and replicas lag by different amounts because MySQL replication is asynchronous by default. The first read hit a replica that had the comment, the second hit one further behind, so time seemed to move backwards. This breaks monotonic reads, which is not the same as read-your-writes, because this user wrote nothing. Fixes: pin each user's session to one replica, for example by hashing the user ID, and move it only if that replica fails; or remember the highest GTID set the user has seen and read only from a replica that has applied it, which MySQL can wait for with WAIT_FOR_EXECUTED_GTID_SET. Take badly lagging replicas out of rotation.
29. You must shard the orders table of a food delivery app. How do you pick the shard key, and what gets harder afterwards?
Pick the key from the main query pattern. Customers mostly open their own order history, so customer_id keeps one person's orders together and that query hits a single shard. Restaurants also need their incoming orders, which would now span every shard, so I would build a separate copy indexed by restaurant_id, fed by events, rather than run scatter-gather queries. Avoid the order date or a sequential order ID as a range key, because all new writes would land on the newest shard. After sharding, cross-shard joins, globally unique IDs, transactions across customers, and moving data when you add shards all get harder, so delay sharding until you need it.
30. Why does hash mod N break when you add a cache server, and how does consistent hashing help?
With server = hash(key) mod N, changing N from 10 to 11 changes the answer for most keys, so most cached entries are suddenly looked up on the wrong server and the hit rate collapses. In the snippet, 90,754 of 100,000 keys moved. Consistent hashing places servers and keys on a ring and gives each key to the next server clockwise, so a new server takes keys only from the points next to it: here 7,420 keys moved, fewer than one in ten. Virtual nodes, many ring points per server, even out the load, an idea described in Amazon's Dynamo paper and used in Cassandra. nginx offers it as the hash directive with the consistent parameter.
import hashlib, bisect
def h(s):
return int(hashlib.md5(s.encode()).hexdigest(), 16)
def ring(nodes, vnodes=100):
return sorted((h(f"{n}#{i}"), n) for n in nodes for i in range(vnodes))
def owner(r, key):
i = bisect.bisect(r, (h(key),)) % len(r)
return r[i][1]
keys = [f"user:{i}" for i in range(100_000)]
old, new = ring([f"c{i}" for i in range(10)]), ring([f"c{i}" for i in range(11)])
print(sum(h(k) % 10 != h(k) % 11 for k in keys)) # 90754 (mod N)
print(sum(owner(old, k) != owner(new, k) for k in keys)) # 7420 (ring)31. When would you use a log like Kafka instead of a work queue like RabbitMQ or SQS?
A work queue hands each message to one worker and removes it once the worker acknowledges it, which suits tasks such as generating payslip PDFs, where many workers share the load. A log like Kafka appends events to partitions and keeps them for a configured retention period even after they are read. Each consumer group tracks its own offset, so the payments, analytics and fraud teams can read the same order events independently, and a team can rewind and replay after a bug. Kafka keeps order within a partition, and events with the same key, such as an order ID, go to the same partition. So use a queue for tasks and a log for event streams.
32. A consumer sends an SMS and then crashes before committing its offset. What happens next, and how do you design for it?
Kafka's documentation says it gives at-least-once delivery by default: the offset is committed after processing, so after the crash the message is delivered again when the consumer restarts or the partition moves to another consumer, and the customer can get a second SMS. You cannot remove redelivery for side effects outside the broker, so make the handler idempotent. Keep a processed-messages table with the message ID as a unique key, record the send, and skip any message already marked sent. A crash in the small gap between sending and recording can still cause a rare duplicate, acceptable for SMS but not for money. Committing before processing gives at-most-once instead, which can silently lose messages.
33. The limit is 100 requests a minute. A client sent 80 last minute and 30 so far, 15 seconds into this minute. Does a sliding window counter allow the next request, and when would you pick a leaky bucket over a token bucket?
A sliding window counter weights last minute's count by the part of the 60-second window still overlapping it: 45 of 60 seconds, so 80 times 0.75 is 60, plus the 30 in this minute gives an estimate of 90. That is under 100, so the request passes, with room for about 10 more. A fixed window would allow 70 more at once, and an exact sliding log would store a timestamp per request. A token bucket allows bursts up to its capacity while holding the average rate, which suits user-facing APIs. A leaky bucket releases requests at a steady rate, which suits a downstream with a hard limit, such as an SMS provider; nginx's limit_req works this way.
def sliding_estimate(prev, curr, elapsed, window=60):
return prev * (window - elapsed) / window + curr
limit = 100
est = sliding_estimate(prev=80, curr=30, elapsed=15)
print(est, est < limit, limit - est) # 90.0 True 10.034. How would you protect an OTP login API from abuse without blocking real users?
Limit on several keys at once: per phone number, for example 3 OTPs in 10 minutes and 10 a day, per IP address and per device, plus a global cap on total SMS spend per hour, because attackers use OTP endpoints to send paid SMS to random numbers at your cost. Enforce a resend cooldown of 30 to 60 seconds on the server, not just in the app. Expire each OTP in a few minutes, allow only a few verify attempts per OTP, and store a hash of the code rather than the code. Show a CAPTCHA only when signals look risky, so normal users are not slowed down, and alert when SMS volume to unusual number ranges spikes.
35. When would you choose REST, gRPC or GraphQL for an API?
REST with JSON over HTTP is the default for public and mobile APIs: it is easy to debug, cache and document, and every client understands it. gRPC uses Protocol Buffers by default to define services and messages, and gives compact binary payloads, generated clients, deadlines and streaming in both directions, so it suits internal service-to-service calls with tight latency, such as a pricing service called on every cart update. GraphQL lets the client ask for exactly the fields it needs in one query, which helps when a mobile home screen needs data from many services, but caching, cost-based rate limiting and blocking very deep queries need extra work. Many companies use REST outside and gRPC inside.
36. How do you change an API without breaking old versions of a mobile app that users have not updated?
Assume old app versions will keep calling your API for months, because many users never update. Prefer additive changes: add new optional fields, never rename or remove fields, never change a field's type or meaning, and make the server cope when new fields are missing. When a breaking change is unavoidable, create a new version, for example /v2/orders, run both, and track how much traffic each app version still sends. The app should send its version in a header, so the server can adapt and, for a dangerously old version, return a response that forces an update. Retire the old version only when its traffic is close to zero and after warning users in the app.
37. Each layer of a five-layer call chain makes up to three attempts when a call fails. What happens to the bottom service during an outage, and how would you change the retry policy?
In the worst case every attempt at one layer triggers three at the next, so one user request becomes 3 to the power 5, or 243, calls to the bottom service, exactly when it is already failing; the AWS Builders' Library warns about this amplification. Retry at one layer only, ideally the one that knows the call is idempotent, and let the other layers fail fast. Give each client a retry budget, for example a token bucket that allows retries for only a small share of traffic. Pass the remaining deadline down the chain, so a lower layer never retries after the caller has already given up. Keep capped exponential backoff with jitter on the retries that remain.
38. Your circuit breaker opens when half the calls in a 10-second window fail. At 3 am it opens on one failed call, and at peak it never opens although one of ten payment pods returns errors. How do you tune it?
At 4 calls a minute, a 10-second window holds at most two calls, so one failure is already 50 percent. Require a minimum number of calls, say 20, or a longer window; Resilience4j has minimumNumberOfCalls and time-based windows. Let slow calls open it too: Resilience4j tracks them as a separate slow-call rate with its own threshold, and a call that times out with an exception counts as a failure. The peak case is not a breaker problem: one bad pod of ten gives about 10 percent errors, far below 50 percent, so eject that host with outlier detection in the load balancer or mesh, as Envoy does. Allow several half-open probe calls, not one.
39. Which metrics would you put on the dashboard of a checkout service, and what would you alert on?
I would start with the four golden signals for the checkout API: traffic, errors split by status code, latency at p50, p95 and p99, and saturation such as CPU, connection pools and queue depth. Next come the dependencies: payment gateway success rate and latency per provider, database query time and inventory service errors. Most important are business metrics: orders per minute compared with the same time last week, and payment success rate per method, such as cards, UPI and net banking. I would alert on symptoms users feel, such as an error rate above a threshold for five minutes or orders dropping sharply, not on every CPU spike.
40. Design the classes for a parking lot in a low-level design round.
Start by asking how many floors there are, which vehicle types are allowed, how pricing works, and whether entry and exit gates issue tickets. Core classes: ParkingLot holds Floors, a Floor holds ParkingSpots, and each spot has a type, such as bike, car or large, and a status. Vehicle carries a type. Ticket records the vehicle, spot and entry time, and Payment records the amount and mode. Put the rules that change behind interfaces: a SpotAllocationStrategy, such as nearest to the gate, and a PricingStrategy, such as hourly or flat weekend rates, so new rules do not change existing classes. Make spot assignment thread-safe so two gates never give out the same spot.
Ready to check yourself? Take the free System Design mock test
System Design interview questions: Hard questions (experienced)
20 questions41. Design a UPI-style payment flow for a merchant app. What happens when the payment partner's response times out?
Each payment is a state machine in a relational database: PENDING, then SUCCESS or FAILED. The merchant app calls our API with an idempotency key; we create the record and call our payment partner. The final status arrives by a signed callback, applied only if the state allows it. On a timeout the payment stays PENDING, never FAILED, since the money may have moved; a status-check job polls the partner, and daily reconciliation against the settlement file resolves the rest. Meanwhile the customer sees payment pending, do not pay again, and we block a second payment for that order. A late SUCCESS for an order already cancelled or paid another way is refunded automatically and logged.
42. Two identical payment requests with the same idempotency key arrive 5 ms apart on different servers. How do you make sure only one charge happens?
Claim the key atomically in a shared store, such as a table with the key as primary key. The first request inserts the key with status PROCESSING and a lease time, then charges. The second insert fails with a duplicate-key error, as the run shows, so it returns the stored response, or 409 while the first is still running. If the first server crashes, the row stays PROCESSING, so after the lease expires a recovery job asks the payment partner for the outcome before any new charge. Send the same key or order reference to the partner too, because our table protects only our side. Reject a reused key with different parameters, as Stripe does.
CREATE TABLE idempotency_keys (
idem_key VARCHAR(64) PRIMARY KEY,
status VARCHAR(16),
lease_until DATETIME,
response VARCHAR(200)
);
INSERT INTO idempotency_keys (idem_key, status, lease_until) VALUES ('ord-981-pay-1', 'PROCESSING', NOW() + INTERVAL 30 SECOND);
INSERT INTO idempotency_keys (idem_key, status, lease_until) VALUES ('ord-981-pay-1', 'PROCESSING', NOW() + INTERVAL 30 SECOND);
-- second INSERT fails: Duplicate entry 'ord-981-pay-1' for key 'idempotency_keys.PRIMARY'43. Design ticket booking for a concert sale where 5 million users arrive in the first 10 minutes.
5 million users in 600 seconds is about 8,300 arrivals a second; if each makes around 10 requests, that is roughly 83,000 requests per second, far more than the seat database should ever see. Put a virtual waiting room in front, which gives users a queue position and lets them in at the rate the booking system can serve. Serve the event page and seat map from a CDN and cache. The seat hold itself must be atomic: a conditional UPDATE that succeeds only if the seat is free or its hold has expired, with an 8-minute hold for payment. In the run, the second user's update changes 0 rows, so they are told the seat is gone.
UPDATE seats
SET status = 'HELD', held_by = 202,
hold_until = NOW() + INTERVAL 8 MINUTE
WHERE seat_id = 7
AND (status = 'FREE' OR (status = 'HELD' AND hold_until < NOW()));
SELECT ROW_COUNT(); -- 0: user 101 already holds seat 744. You use a Redis lock so that only one worker settles each merchant's payout. Why is that not enough for correctness?
A lock taken with SET key value NX PX expires after its timeout. If the worker pauses longer, say in a garbage-collection pause, a second worker takes the lock and both settle the payout. Redis can also lose a lock on failover, because replication is asynchronous and a promoted replica may lack the key, as its documentation explains. Martin Kleppmann's analysis adds that neither this pattern nor Redlock produces fencing tokens, the increasing numbers a payout ledger can check to reject a stale writer. The token must come from a store that issues one, such as a database sequence, a row version or a ZooKeeper zxid. For money, a unique payout row per merchant and period is the real guard.
45. The order service saves to MySQL and then publishes an OrderPlaced event, and sometimes the event is lost. How do you fix this dual-write problem?
Writing to the database and then publishing to the broker is a dual write: if the service crashes between the two steps, or the publish fails, the order exists but no event goes out, and the restaurant never hears about it. Publishing first and saving second just fails the other way round. The transactional outbox pattern fixes this. In the same local transaction that inserts the order, insert the event into an outbox table. A relay process, either polling the table or reading the database change log, publishes the events and marks them sent. Because the relay can publish an event twice after a crash, consumers must be idempotent, for example by tracking processed event IDs.
46. In a food-order saga, the restaurant rejects the order and the refund call to the payment service then fails three times. What should the orchestrator do?
The orchestrator must never lose track, so it stores the state of each order's saga step by step in its own table and resumes from there after a crash. The refund carries a fixed idempotency key built from the order ID, so every retry asks for the same refund instead of a new one. It retries with capped exponential backoff and jitter for a bounded time, say a few hours, and checks the payment partner's refund status before each new attempt, because a timed-out call may have worked. After that, it parks the case in a manual-review queue and alerts the on-call team. Meanwhile the customer sees the order as cancelled with the refund in progress, never a silent failure.
47. Should a wallet balance, a like counter and a chat thread all use the same consistency model?
No. Choose per data type by asking what a stale or reordered read would cost. A wallet balance needs strong consistency: debit and credit inside one database transaction with a row lock or a conditional update, so two parallel payments can never take the balance below zero, and payment decisions read from the primary. A like counter can be eventually consistent: buffer increments and update the count every few seconds, and nobody is harmed if it shows 1,203 instead of 1,205. A chat thread needs ordering within one conversation, not across the whole system, so a per-conversation sequence number is enough. Strong consistency everywhere costs latency and availability for no benefit.
48. With N = 3 replicas, what do R = 2 and W = 2 guarantee, and what can still go wrong?
W = 2 means a write is acknowledged once two replicas have stored it, and R = 2 means a read asks two replicas and takes the newest version. Since R plus W is 4, more than 3, every read set overlaps every write set in at least one replica, so a read can see the latest acknowledged write; the Dynamo paper describes this as a quorum-like system, and Cassandra gets the same effect with QUORUM reads and writes. Still, a sloppy quorum with hinted handoff may place writes on stand-in nodes, concurrent writes need a conflict rule such as last-write-wins that can drop data, and a failed write that reached one replica may still be read later.
49. Your app runs in two Indian cloud regions. Would you run active-active or active-passive, and what breaks with active-active?
Active-passive is simpler: one region takes all writes, and the other holds replicated data and warm capacity, ready to take over in minutes, with a possible loss of the last few seconds of asynchronously replicated writes. Active-active serves users from both regions, which helps latency and uses both regions' capacity, but anything that needs a single truth breaks: both regions may sell the last seat or accept the same username, and conflicting edits need a resolution rule. A common answer is a home region per user or merchant for writes, with local reads. If you are a payment system provider, the RBI's April 2018 directive on storage of payment system data requires that data to be stored only in India.
50. One seller's flash-sale product gets 40 percent of all traffic, and its shard is overloaded. What do you do?
First protect the system. Put the product page and stock status behind the cache and CDN, and coalesce identical reads so the shard sees one request per key per short window instead of thousands. For writes, the stock counter is the hot spot, so split it: divide the sale stock into, say, 20 sub-counters on different keys or shards, decrement one atomically per order, and move to another when one runs out. Put order creation on a queue so it is processed at a steady rate. Longer term, choose shard keys that spread load, move known hot sellers to dedicated capacity before a sale, and load-test with the real traffic skew, not uniform traffic.
51. Peak traffic is 6,000 requests per second, p99 latency is 200 ms, and each instance can work on 100 requests at a time. How many instances do you run?
Little's law says requests in flight equal the arrival rate times the time each request spends in the system: 6,000 per second times 0.2 seconds is 1,200 requests in flight. Using the p99 instead of the average latency is a deliberately cautious choice. At 100 concurrent requests per instance, that is 12 instances running flat out, which is too tight. Running at about 70 percent utilisation leaves room for spikes and slow dependencies: 12 divided by 0.7 is about 17.1, so 18 instances. To survive losing one of three availability zones, the remaining two zones must hold all 18, which means 9 per zone and 27 in total. Then confirm it with a load test.
52. Your rate limiter uses Redis and must handle 200,000 requests per second across 40 gateway nodes. How do you keep it fast, and what happens when Redis is down?
200,000 requests a second across 40 nodes is 5,000 per node. A Redis call on every request adds a network hop, so keep the exact central check only where it matters, such as OTP sends and paid API quotas, using an atomic Lua script or INCR with an expiry so check and update cannot race. For general API limits, each gateway keeps a local token bucket and syncs its counts to Redis in batches every few hundred milliseconds, accepting a small overshoot. Spread keys across a Redis cluster so no node is hot. If Redis is down, fail open for ordinary traffic with a strict local fallback limit, but fail closed for costly actions such as SMS.
53. Each search request fans out to 50 shards. Why is the request's p99 much worse than any single shard's p99, and what do you do?
The request finishes only when the slowest shard answers. If each shard is slower than its p99 1 percent of the time, the chance that at least one of 50 is slow is 1 minus 0.99 to the power 50, about 39.5 percent. So a rare delay on one shard becomes common for the whole request. Fixes: send a backup request to another replica if the first has not answered by the 95th percentile time, and cancel the slower one; return partial results after a deadline when a few shards are late; route each query only to shards that can match; and remove the causes of slow shards, such as garbage-collection pauses, noisy neighbours or compaction.
54. Design live location tracking for 500,000 delivery partners who each send their position every 4 seconds.
500,000 partners every 4 seconds is 125,000 location updates a second, about 10.8 billion a day, so writing each one as a database row is wasteful. Partners send updates over a persistent connection to a location gateway, which keeps only the latest position per partner in memory in a geo index, such as Redis geospatial commands or a grid of geohash or H3 cells. The dispatch service then asks for free partners within 3 km of a restaurant. Raw points go to a stream such as Kafka for trip history and ETA models, and are sampled or compressed before long-term storage. A customer tracking one order subscribes only to that partner's updates instead of polling.
55. How would you check whether a username or phone number is already taken among 1 billion records without hitting the database every time?
Use a Bloom filter: a bit array with k hash functions that answers definitely not present or possibly present, with no false negatives for items that were added. It only speeds up the live availability check. At signup the INSERT still relies on a unique index on the normalised username or phone, because two people can pass the check at the same moment. Keep one shared filter, such as a Redis Bloom filter, and add every new name on insert; a copy in each server's memory goes stale and is only a hint. For 1 billion entries at a 1 percent false positive rate, that is about 9.6 bits per item, roughly 1.2 GB, with 7 hash functions.
import math
def bloom_size(n, p):
m = -n * math.log(p) / math.log(2) ** 2 # bits
k = round(m / n * math.log(2)) # hash functions
return m, k
m, k = bloom_size(1_000_000_000, 0.01)
print(round(m / 8 / 1e9, 2), "GB,", k, "hashes") # 1.2 GB, 7 hashes56. How do services authenticate users and each other in a microservices system?
Users log in once at an auth service, which issues a short-lived access token, for example a signed JWT valid for 15 minutes, and a refresh token that is stored on the server side and can be revoked. The API gateway checks the signature and expiry on every request and passes the user ID and roles downstream. Each service must still check that this user may act on this record, such as this employer owning this job post, because the gateway cannot know that. For calls between services, use mutual TLS or workload identities, with separate credentials and least-privilege permissions for each service. Never trust a user ID that arrives in the request body.
57. Your storage grows by about 70 TB a year. How would you cut the cost without losing data you need?
First find out what the 70 TB is, such as user uploads, logs, backups or analytics copies, and how often each kind is read after 30, 90 and 365 days. Then apply lifecycle rules: keep recent data on the standard tier, move objects that are rarely read after 90 days to an infrequent-access tier, and move old data kept only for compliance to an archive tier, accepting retrieval delays of hours. Compress logs and store analytics data in a columnar format. Delete data with no owner or purpose, such as stale debug logs and duplicate copies, under a written retention policy. Since 70 TB a year is about 5.8 TB a month, present the saving as a monthly bill forecast.
58. In a food delivery order service, the partner app sends DELIVERED before PICKED_UP arrives and retries the same event, while a customer cancels at the moment the partner marks pickup. How do you design the state handling?
Every event carries an event ID and the sender's sequence number for that order. Store processed event IDs under a unique key, so a retried event is acknowledged and ignored. If DELIVERED arrives while the order is still ACCEPTED, hold it briefly for the missing PICKED_UP, or apply an agreed rule that a confirmed delivery implies pickup, and record why. For the race, every change is a conditional update on the expected status and a version column, as in the run: the pickup commits first, and the cancel then changes 0 rows, re-reads the order and follows the after-pickup rule. A transition table also says who may make each move, for example customers cancel only before pickup.
UPDATE orders SET status = 'PICKED_UP', version = version + 1
WHERE order_id = 5501 AND status = 'ACCEPTED' AND version = 3;
SELECT ROW_COUNT(); -- 1: the partner's pickup wins
UPDATE orders SET status = 'CANCELLED', version = version + 1
WHERE order_id = 5501 AND status = 'ACCEPTED' AND version = 3;
SELECT ROW_COUNT(); -- 0: the cancel lost, so re-read the order59. Tell me about a time you pushed back on a design in a review.
Use STAR with a real example of your own. A strong one sounds like this. Situation: a team planned to move payout reconciliation to a new NoSQL store mainly because it was popular. Task: as the reviewer, you had to judge whether it was safe for money. Action: you asked for the access patterns, showed that reconciliation needs multi-row transactions and ad hoc audit queries, and benchmarked the existing MySQL setup with one new index to show it had enough headroom. You proposed the smaller change and offered to help build it. Result: it shipped sooner with less risk. Interviewers check that you disagree with evidence and respect, and that you would change your mind if the data said so.
60. A junior engineer proposes splitting a three-person team's monolith into 12 microservices. How do you respond?
I would start from the problem, not the architecture: what hurts today, slow deploys, scaling limits or unclear code ownership? For three engineers, 12 services means 12 pipelines, network calls instead of function calls, distributed debugging and data spread across databases, with nobody free to run it all. I would suggest a modular monolith: clear modules with their own interfaces and tables inside one deployable, which keeps the option of extracting a service later. Then we agree on signals that would justify a split, such as one module needing to scale very differently or a separate team owning it. I would run this as a discussion and credit what the proposal got right.
Practice questions for November 2026
New every month3 questions from the System Design mock test, the way they appear in it. A new set comes on the 1st of every month. Pick your answer, then open it.
-
A system stores 100 GB of new data every day and keeps everything. About how much does it add in a 365-day year? (1 TB = 1,000 GB.)
- 365 TB
- 36.5 TB
- 12 TB
- 3.65 TB
Show the answer
Answer: 36.5 TB. 100 GB x 365 = 36,500 GB = 36.5 TB a year, before replication. 3.65 TB and 365 TB shift the decimal point; 12 TB treats a year as 120 days. Replicas and backups multiply the real disk needed.
-
A service writes a new object to Amazon S3 and immediately reads it with GET. What does S3 guarantee today?
- Strong read-after-write consistency: the GET returns the new object
- The GET succeeds only if versioning is enabled on the bucket
- Eventual consistency: the GET may return 404 for several minutes
- The GET returns the object only from the same Availability Zone
Show the answer
Answer: Strong read-after-write consistency: the GET returns the new object. S3 provides strong read-after-write consistency for PUTs and DELETEs, and LIST reflects changes too. Older design notes that warn about eventual consistency on new objects describe the behaviour before the change, not today's.
-
A token bucket and a leaky bucket are both set to an average of 10 requests per second. What is the key behavioural difference?
- The leaky bucket drops every request above 1 per second
- Token bucket allows bursts up to its size; leaky bucket drains at a steady rate
- Only the token bucket can be used for APIs
- Leaky bucket allows bursts up to its size; token bucket drains at a steady rate
Show the answer
Answer: Token bucket allows bursts up to its size; leaky bucket drains at a steady rate. Saved tokens let a client burst up to the bucket size, then continue at the refill rate. A leaky bucket queues requests and drains them at a fixed rate, smoothing bursts (or dropping when the queue is full).
Ready to apply?
Browse the open jobs on CoreHRx. Create a free profile once and apply with it.