HLD and LLD: caching, sharding, queues, consistency and consensus, reliability, back-of-envelope estimates, classic designs and Indian products like UPI.
Every question has why it is asked, a full answer, what the interviewer listens for, follow-ups, common mistakes and a diagram.
Made by systemdesign.academy, the site with 984 interactive system design and AI engineering lessons.
See all 200 questions in this pack15 sections, in the order the PDF prints them. The answers are in the PDF; 5 are free below.
Latency and throughput (10)
1.What is the difference between latency and throughput? Can a system have good throughput and bad latency? junior
2.How are bandwidth, latency and throughput different? When does a faster network link not make your page load faster? junior
3.Why do engineers talk about p50, p95 and p99 latency instead of the average, and how do you get one p99 across 50 servers? junior
4.What is Little's Law, and how would you use it to size a thread pool or connection pool? junior
5.Give rough latency numbers for a memory read, an SSD read, a network round trip in a data center, a disk seek and a cross-continent round trip. Why do they matter in design? junior
6.A page calls 100 backend servers in parallel and waits for all of them. Each server is slow only 1% of the time. How often is the page slow, and what can you do about it? midfree below
7.Why does latency shoot up when a server goes from 70% to 95% CPU, even though it still has spare capacity? mid
8.A mobile app in India calls an API hosted in the US. The first request takes about 600 ms but later ones take about 200 ms. Explain why, and how you would reduce it. mid
9.An order pipeline has four stages: validate (5,000/s), enrich (1,200/s), price (3,000/s) and save (2,500/s). What is the throughput of the whole pipeline, and how do you find and fix the bottleneck in a real system? mid
10.Your load test reports a p99 of 1 ms, but users complain about multi-second delays. What could be wrong with the measurement? senior
Back-of-envelope estimation (10)
11.How do you approach a back-of-the-envelope estimate in a system design interview? junior
12.An app has 100 million daily active users and each user makes about 10 requests a day. Estimate average and peak requests per second. junior
13.Which powers of two and unit conversions should you know by heart for system design estimates? junior
14.Estimate the storage needed for photos in an Instagram-like app that receives 10 million photo uploads per day, over 5 years. mid
15.Estimate the gateway servers and memory needed to hold 50 million concurrent WebSocket connections, and the traffic the heartbeats alone produce. mid
16.You have 100 million items, each about 2 KB, and want to cache the hot ones. How much memory do you need, and what hit rate can you expect? mid
17.Peak traffic is 60,000 requests per second and one server handles about 2,000 requests per second. How many servers do you need? mid
18.Estimate the storage for posts in a Twitter-like service with 200 million daily active users over 5 years. What would you store where? senior
19.A database needs 20,000 random reads per second from disk. How many disks do you need with hard drives versus SSDs, and what usually decides the answer? senior
20.You need to ingest 200,000 events per second of about 1 KB each into Kafka and keep them for 7 days. Estimate throughput, storage and partition count. senior
APIs and rate limiting (9)
21.When would you choose REST, gRPC or GraphQL for an API? junior
22.Which HTTP methods are idempotent, and why does it matter when a client retries? junior
23.For live updates, such as a delivery tracker or a chat, how do you choose between polling, long polling, Server-Sent Events and WebSockets? junior
24.Why is offset pagination (LIMIT 20 OFFSET 100000) a problem, and how does cursor pagination fix it? mid
25.How do you version a public API, and how do you retire an old version without breaking clients? mid
26.Compare the token bucket and leaky bucket rate-limiting algorithms. What happens to a sudden burst under each? mid
27.A fixed-window limiter allows 100 requests per minute. How can a client still send 200 requests in about two seconds, and how do sliding windows fix it? mid
28.Where should rate limits be enforced in a large system, and what should the API return to a limited client? senior
29.Your rate limiter uses Redis GET then SET across many gateway nodes, and clients exceed their limit under load. Why, and how do you fix it? senior
Scaling and load balancing (12)
30.What is the difference between vertical and horizontal scaling? When would you choose each? junior
31.What does it mean for a service to be stateless, and where do you keep user session data? junior
32.What is the difference between a Layer 4 and a Layer 7 load balancer? junior
33.Explain round robin, weighted round robin and least connections. When does round robin work badly? junior
34.How do load balancer health checks and connection draining work during a deploy? junior
35.What are sticky sessions, and what problems do they cause at scale? mid
36.Can you use DNS for load balancing and failover? What is the problem with DNS TTLs? mid
37.What is the difference between a reverse proxy, a load balancer and an API gateway? mid
38.Your service autoscales on CPU, yet users still see errors during traffic spikes. Why, and how would you fix it? mid
39.What is the 'power of two choices' in load balancing, and why does it work so well? mid
40.Your users are in India, Europe and the US. How do you route each user to the best region, and what happens when a region fails? senior
41.The load balancer itself is a single point of failure. How do you make it highly available? senior
Caching and CDNs (14)
42.Why do we cache, and where can caches live in a typical web system? junior
43.Walk me through the cache-aside pattern for reads and for writes. junior
44.What are TTL, LRU and LFU in caching? Which would you use? junior
45.Redis or Memcached: how do you choose? junior
46.Compare write-through, write-back and write-around caching. When is each a good idea? mid
47.Even with 'update the database, then delete the cache', a user sometimes sees stale data for minutes. How can that happen? mid
48.A very popular cache key expires and the database suddenly gets thousands of identical queries. What is this, and how do you prevent it? mid
49.Attackers request random product IDs that do not exist, so every request misses the cache and hits the database. How do you protect it? mid
50.Redis offers RDB snapshots and an AOF log. What can you lose on a crash with each, and which would you pick for a session store, a rate limiter and a leaderboard? mid
51.How does a CDN work? Explain pull versus push, and what an origin shield does. mid
52.You ship a new version of your web app, but some users still get the old JavaScript from the CDN. How should you handle cache keys and invalidation for static assets? senior
53.Explain how Cache-Control, ETag and a 304 Not Modified response work together. senior
54.You use a local in-process cache on each app server plus a shared Redis cache in front of the database. How stale can data get, and how do you keep the layers consistent? senior
55.Your Redis cluster restarts and comes back empty during peak hours. The database, which normally sees 5% of reads, falls over. How do you design so this cannot take you down? staff
Storage and replication (13)
56.SQL or NoSQL: how do you choose a database for a new feature? junior
57.How does a database index make reads faster, what does it cost, and why does column order matter in a composite index? junior
58.What does ACID mean? Give a real example of each property. junior
59.Explain the common transaction isolation levels and the anomalies each one prevents. mid
60.Compare B-tree and LSM-tree storage engines. Which would you pick for a write-heavy workload? mid
61.What is the difference between block, file and object storage? Where would you store user photos, a database's data files and shared config files? mid
62.Explain synchronous, asynchronous and semi-synchronous replication. What does each cost? mid
63.What is a write-ahead log, and how does it make a database durable after a crash? mid
64.A user edits their profile, the page reloads, and the old name shows. Reads go to replicas. What is happening and how do you fix it? senior
65.With asynchronous replication, the leader crashes and a follower is promoted. What can go wrong, and how do you reduce the risk? senior
66.You run a database with a leader in each of two regions (multi-leader). What happens when both regions update the same record, and how do you resolve it? senior
67.In a leaderless (Dynamo-style) store with N = 3 replicas, explain how read and write quorums work and why R + W > N matters. senior
68.You must add a column and change how an existing column is stored on a 2-billion-row MySQL table that serves live traffic. How do you do it without downtime? staff
Partitioning and sharding (12)
69.What is the difference between partitioning (sharding) and replication? Do you need both? junior
70.Compare range partitioning and hash partitioning. What goes wrong if you range-partition orders by creation date? junior
71.How do you choose a shard key? Evaluate user_id, country and created_at for a social app's posts table. mid
72.How does consistent hashing work, and why are virtual nodes used? mid
73.Sharding by user_id works well until a celebrity with 50 million followers posts. Their shard melts. What do you do? mid
74.You need to move from 8 to 16 database shards while the system is live. Walk through the process. mid
75.After sharding by user_id, the product team wants 'top 10 most-liked posts this week across all users'. How do you answer cross-shard queries? mid
76.In a sharded database, what is the difference between a local and a global secondary index? When would you use each? senior
77.What is directory-based sharding, and why might you choose it over pure hash-based placement? senior
78.Design a way to generate unique, roughly time-ordered 64-bit IDs across hundreds of servers without a central database. senior
79.For a multi-tenant SaaS, would you put all tenants in shared tables with a tenant_id column, or give each tenant its own database? What about a mix? senior
80.A team proposes sharding the main PostgreSQL database because it is 'getting slow'. As the staff engineer, what do you ask and what would you try first? staff
Queues, streams and idempotency (14)
81.Why would you put a message queue between two services? junior
82.What is the difference between a work queue, publish/subscribe and a log like Kafka? junior
83.Explain at-most-once, at-least-once and exactly-once delivery. junior
84.How do Kafka partitions, message keys and consumer groups work together? What ordering does Kafka guarantee? junior
85.How do you make a message consumer idempotent? mid
86.Consumer lag on your Kafka topic keeps growing. How do you diagnose it and bring it back down? mid
87.One malformed message makes your consumer crash every time, and the queue stops moving. How do you handle poison messages? mid
88.Your order service writes to the database and then publishes an 'OrderPlaced' event to Kafka. Sometimes the event is missing. Why, and what is the transactional outbox pattern? mid
89.What is change data capture (CDC), and how would you use it to keep a search index and a cache in sync with your database? mid
90.Kafka advertises exactly-once semantics. What exactly does it guarantee, and where does it stop? senior
91.Explain Kafka retention, log compaction and replay. When would you use a compacted topic? senior
92.OrderCreated and OrderPaid events for the same order sometimes arrive in the wrong order at a consumer. Why, and how do you fix it? senior
93.Design a way to deliver millions of scheduled messages, such as 'send a reminder 24 hours after sign-up', at the right time. senior
94.Teams are debating whether services should call each other synchronously or communicate through events. How do you decide, as the staff engineer? staff
Consistency, CAP and PACELC (12)
95.State the CAP theorem correctly. Why is 'pick any two of three' misleading? junior
96.What is the difference between strong consistency and eventual consistency? Give an example where each is the right choice. junior
97.What does PACELC add to CAP? Place two real databases in it. mid
98.What is the difference between linearizability and serializability? mid
99.Explain read-your-writes, monotonic reads and monotonic writes. Show one violation. mid
100.What is causal consistency? Give an example where its absence confuses users. mid
101.A leaderless store uses N = 3, W = 2, R = 2. Can two clients still see inconsistent results? How? senior
102.What are vector clocks (version vectors), and what problem do they solve that timestamps do not? senior
103.What is a CRDT? Explain how a grow-only counter merges, and where CRDTs are used. senior
104.Why are wall-clock timestamps unsafe for ordering events across machines? What do Lamport clocks and Google's TrueTime do differently? senior
105.You are designing an e-commerce platform. How do you decide the consistency level for different features, and how do you explain the decision to product managers? staff
106.Leadership wants 'strongly consistent writes across three continents'. What will each write cost, and what would you propose? staff
Consensus and coordination (9)
107.Why do distributed systems need consensus algorithms like Raft or Paxos? Where are they used? mid
108.Why are consensus clusters usually 3 or 5 nodes, and why not 4 or 6? mid
109.Walk me through how Raft elects a leader. mid
110.How does Raft replicate log entries and decide that an entry is committed? senior
111.A process holds a distributed lock with a lease, pauses for a long garbage collection, and wakes up after the lease expired. What can go wrong, and how do fencing tokens help? senior
112.Compare a Redis-based lock with a lock built on etcd or ZooKeeper. When is each acceptable? senior
113.How does two-phase commit work, and why is it called a blocking protocol? senior
114.What is the saga pattern? Design a saga for placing an order that reserves stock, charges payment and books delivery. senior
115.You run 6 instances of a service, but a nightly settlement job must run exactly once. How do you design leader election for it, and what guarantees can you really give? staff
Reliability and resilience (16)
116.What do 99.9%, 99.99% and 99.999% availability mean in actual downtime? junior
117.What is the difference between an SLI, an SLO and an SLA? junior
118.Why must every network call have a timeout, and how do you choose its value? junior
119.In Kubernetes, what is the difference between a liveness probe and a readiness probe? junior
120.Your service calls three dependencies in sequence, each 99.9% available. What is your best possible availability, and how does redundancy change it? mid
121.What is an error budget, and how does it decide whether a team can ship new features? mid
122.Why should retries use exponential backoff with jitter? Show what happens without jitter. mid
123.Explain how a circuit breaker works, including its three states. mid
124.What is the bulkhead pattern? Give an example where it prevents a total outage. mid
125.Each layer of a five-service call chain retries failed calls up to 3 times. What happens when the deepest service is overloaded? senior
126.What is load shedding, and why can it keep more users happy during overload than trying to serve everyone? senior
127.How do you design graceful degradation for an e-commerce product page when some dependencies fail? senior
128.How do metrics, logs and traces differ, and what are the RED and USE methods? senior
129.Many of our outages started with a configuration change. Design how config changes reach 50,000 servers safely. staff
130.Leadership asks: 'Can we survive the loss of an entire cloud region?' How do you answer, and what are the options? staff
131.How do you run a blameless postmortem, and how do you choose follow-up actions that actually reduce risk? staff
Low-level design (12)
132.Design the classes for a parking lot system. junior
133.Model an elevator's states and the events that move it between them. junior
134.Implement an LRU cache with O(1) get and put. junior
135.Two cars arrive at two entry gates at the same moment and the system assigns both to the same last free spot. How do you prevent double assignment? mid
136.How should an elevator decide which floor to serve next? Compare first-come-first-served with the LOOK algorithm. mid
137.Your LRU cache is used by 64 threads and a single lock has become a bottleneck. How do you make it fast and still correct? mid
138.Design an in-memory key-value store with SET, GET, DELETE, COUNT(value) and nested transactions using BEGIN, ROLLBACK and COMMIT. mid
139.Design the data model and core classes for a Splitwise-like expense sharing app. mid
140.In the Splitwise app, how do you 'simplify debts' so a group needs fewer payments? Write the algorithm. senior
141.Design the core classes for a movie ticket booking system like BookMyShow. senior
142.Two users try to book seat F12 for the same show at the same moment. How do you guarantee only one succeeds, and release the seat if payment never happens? senior
143.Draw the booking state machine for a ticketing system, including payment timeouts and cancellations. senior
Classic system design problems (27)
144.We have 45 minutes to design a ride-sharing app. Before you draw anything, tell me what you will clarify and how you will spend the time. junior
145.Design a URL shortener like bit.ly. What are the requirements and the API, what happens when a link is created and when it is clicked, and should the redirect be a 301 or a 302? juniorfree below
146.For a URL shortener, compare three ways to make short codes: a counter encoded in base62, a hash of the URL, and a random code. How many characters do you need? mid
147.Design one-to-one chat like WhatsApp. How does a message get from the sender's phone to the receiver's phone, including when the receiver is offline? mid
148.In a chat app, how do you keep messages in order within a conversation, show sent, delivered and read receipts, and keep a user's phone and laptop in sync? mid
149.Design the news feed for a social app. Would you use fan-out on write or fan-out on read? mid
150.Design a notification system that sends push, SMS and email for many product teams. How do you handle priorities, templates and user preferences? mid
151.Design the core of a ride-hailing app like Uber. How do you ingest driver locations, and how do you match a rider with a nearby driver? mid
152.Design a payment system for an e-commerce checkout. How do you use idempotency keys, a double-entry ledger, and a payment service provider (PSP)? mid
153.Design product search for an e-commerce site. Cover the index, sharding and replicas, the query path, and how results stay fresh. mid
154.Design search autocomplete (typeahead). How do you return the top suggestions for each prefix within the latency budget? mid
155.Design video upload and streaming for a platform like YouTube. Cover the upload, the transcoding pipeline, the bitrate ladder and the CDN. mid
156.Design a metrics monitoring system like Prometheus. Would you pull or push metrics, how do you store time series, and why does label cardinality matter? mid
157.Your feed uses fan-out on write, but celebrity posts overload it. How does a hybrid design work, how big is the feed cache, and where does ranking happen? senior
158.How do you make sure a notification system never sends duplicates, respects quiet hours, fails over between SMS providers, and retries without spamming users? senior
159.For finding nearby drivers, compare geohash, quadtrees and Uber's H3. How do you handle a hot cell, such as an airport with hundreds of waiting drivers? senior
160.Your call to the payment provider times out. Did the customer pay? How do you design the payment state machine and reconciliation so no money is lost or charged twice? seniorfree below
161.Design an internal distributed cache service that many teams share. How do you handle partitioning, replication, failover and routing requests to the right node? senior
162.Design a Dynamo-style key-value store. Explain how it partitions data, replicates it, uses hinted handoff, and repairs drift with anti-entropy. senior
163.Design a web crawler that fetches 1 billion pages a month. How do you build the URL frontier, stay polite to websites, and avoid duplicates? senior
164.Design a Dropbox-style file sync service. How do chunking, content hashes and deduplication work, and how do you handle conflicting edits? senior
165.Design real-time trending hashtags: show the top 10 hashtags of the last hour, updated every minute, at a very high event rate. senior
166.Design a feature flag system that 300 services use to turn features on per user, per region or by percentage. senior
167.As the staff engineer for a video platform, estimate the storage and delivery cost of the bitrate ladder, and decide whether every video should be encoded the same way. staff
168.Size a key-value cluster that stores 1 PB of data and serves 10 million operations per second. What limits it first? staff
169.Design a logging pipeline for 1 million log lines per second. How do you collect, buffer, index and store the logs, and what does it cost? staff
170.Design collaborative editing like Google Docs. Would you use operational transformation or CRDTs, how does the server order edits, and how do you handle presence and history? staff
Indian product design problems (14)
171.Walk me through a UPI person-to-person payment. What do the payer's app, the PSP, the NPCI switch and the two banks each do? midfree below
172.Tatkal booking on IRCTC opens at 10:00 for AC classes, and hundreds of thousands of people press the button in the same second. Why does such a system struggle, and how would you design a waiting room in front of it? mid
173.Design the order flow for a food delivery app like Zomato or Swiggy, from 'Place order' to 'Delivered'. mid
174.Why is a live cricket stream often 20 or more seconds behind TV, and how do shorter segments and Low-Latency HLS reduce that delay? What do you give up? mid
175.A user says: 'UPI money was debited from my account, but my friend never received it.' How should the payer's PSP backend handle this payment, from the timeout to the final credit or reversal? senior
176.Design the seat inventory for Indian Railways-style bookings, where one berth can be sold for different parts of the route and berths are split into quotas such as General and Tatkal. How do you prevent overselling when thousands book the same train at once? senior
177.How would you assign delivery partners to food orders, when should two orders go to one partner, and what goes into the delivery ETA? senior
178.Design 10-minute grocery delivery like Blinkit or Zepto. How do you pick the dark store for an address, keep store stock accurate, and get an order out of the door in about 2 minutes? senior
179.Design live streaming for a cricket match watched by tens of millions of people at the same time. How do the CDN, adaptive bitrate, origin shield and pre-warming fit together? senior
180.A shopping app will sell 1,000 units of a phone at a big discount at midnight, and about 2 million users will try to buy. Design the reservation, the queue and the payment window so nothing is oversold. senior
181.You run the backend of a large UPI app and Diwali is coming. How do you size it for the festival peak, what do you do about banks that cannot keep up, and how do you degrade? staff
182.Tatkal tickets keep going to bots and touts. As the staff engineer, how would you make Tatkal booking fairer, and how would you prove that it is fairer? staff
183.During a big cricket match, the video holds up but interactive features (live score, chat, polls, ads shown at the end of each over) keep failing at the same moments. How do you design and prepare for these spikes? staff
184.Your e-commerce platform expects more than 10 times its normal peak during a festival sale such as Flipkart's Big Billion Days. You have eight weeks. How do you prepare the whole platform? staff
Senior and staff trade-offs (16)
185.You join a 15-engineer startup that is planning to split its product into 12 microservices. What would you recommend? senior
186.A team wants to add Kafka between two services 'to decouple them'. When would you say no? senior
187.Your team needs product search. Should you build it on open-source Elasticsearch or OpenSearch yourselves, or buy a hosted search service? How do you decide? senior
188.Many services consume your OrderPlaced event. How do you change its schema without breaking any of them? senior
189.You must move a 600-million-row orders table from MySQL to DynamoDB, where data is modeled around access patterns instead of joins. How do you migrate with no downtime and prove the new model answers every query? stafffree below
190.What is a cell-based architecture, and when would you move a large service to it? staff
191.Your product's traffic is expected to grow 10x in two years. Leadership asks whether the system should be built for 100x. What do you say? staff
192.Finance asks you to cut the cloud bill by 30% this year without hurting reliability. How do you approach it? staff
193.You are designing a payments product in India for a global company. How do the Reserve Bank of India's (RBI's) payment data storage rule and the DPDP Act shape the architecture? staff
194.Your checkout depends on a bank's payment API that you do not control and that fails a few times a month. How do you design around it? staff
195.You are the senior reviewer in a design review for a new service. What do you look for, and how does the review end? staff
196.Your company wants to switch off a 12-year-old billing system. How do you decommission it safely? staff
197.You lead a platform team building a 'paved road' for 40 product teams. How do you get teams to adopt it without forcing them? staff
198.Engineers say technical debt is slowing everything down, and product leaders keep saying there is no time to fix it. How do you handle this? staff
199.The p99 latency of checkout rose 40% over two weeks, and no team says it deployed anything related. How do you investigate? staff
200.The accounts team and the orders team both want to own 'customer' data, and every change now needs both teams. How do you settle the service boundaries? staff
A curve of the probability that a page is slow against the number of parallel calls, rising from 1% at one call to 63% at 100 calls.
Why it is asked: This is the classic tail-at-scale question. It tests whether you can turn a per-server percentile into a user-facing probability and know the mitigations.
The page is slow about 63% of the time. The page is fast only if all 100 calls are fast. The chance of that is 0.99 multiplied by itself 100 times (0.99^100), about 0.366, because each call is independently fast 99% of the time. So the chance that at least one call is slow is 1 - 0.366 = 0.634, roughly 63%.
With 10 parallel calls it is already about 9.6%. This effect is called tail latency amplification: the more calls you fan out to, the more a rare slow server becomes the common case.
What helps:
- Hedged requests: if a call has not returned by the p95 time (the time that 95% of calls beat), send a second copy to another replica and use the first answer. This was popularized by Google's 'The Tail at Scale' paper.
- Fewer fan-out calls: aggregate data so one request needs fewer servers.
- Partial results: return what arrived within the deadline (common in search) instead of waiting for every shard (each server holding one slice of the data).
- Fix the causes of slowness on each server: GC pauses (the runtime freezing to free memory), noisy neighbors (other jobs on the same machine), and background compaction (the database reorganizing its files).
- Tight per-call timeouts with a total deadline.
Hedging adds some load, so limit it, for example to 5% extra requests.
What the interviewer listens for
P(page slow) = 1 - 0.99^100, about 63%
Fan-out turns a 1% tail into the common case
Hedged requests, partial results and fewer fan-out calls
Budget the extra load that hedging creates
Follow-ups the interviewer may ask
When should the hedge fire? Hint: around the p95 latency, so you only duplicate the slowest few percent.
Why can hedging make things worse? Hint: if the slowness is caused by overload, duplicates add more load; cap the hedge rate.
Common mistakes
Answering '1%' because each server is slow 1% of the time.
Retrying immediately everywhere, which multiplies load during an incident.
Three tiers: a browser and a creator app on the left, a link API and a redirect service in the middle, and Redis for code lookups, PostgreSQL for the links table and an async click queue on the right.
Why it is asked: The classic warm-up design. It checks that you can state requirements, size the system, and build a fast read path, plus one real HTTP detail.
A URL shortener stores a mapping from a short code to a long URL and answers every click with an HTTP redirect to the long URL. Clicks far outnumber new links, so the design centers on a fast, cached redirect.
Requirements: create a short link (optionally with a custom alias and expiry), redirect quickly, keep links working for years. Assume 30 million new links a month and 100 clicks per link. A month is about 2.6 million seconds, so 30 million / 2.6 million = about 12 writes per second, and 3 billion clicks / 2.6 million = about 1,157 redirects per second, roughly 3,500 at a 3x peak. At 500 bytes per row, five years is 1.8 billion rows, about 0.9 TB, which one database with replicas holds.
API:
- POST /api/links {long_url, alias?, expires_at?} returns 201 with the short URL.
- GET /{code} redirects to the long URL (Location header).
Create path: validate the URL, get a unique code (a counter in base62, a hash or a random string), insert (code, long_url, owner, created_at) with the code as primary key, return the link.
Click path: look up the code in Redis; on a miss, read PostgreSQL and fill the cache; return the redirect, or 404 if the code is unknown or expired. Record the click asynchronously so analytics never slows the redirect.
301 or 302: a 301 (moved permanently) lets browsers cache the redirect, so repeat clicks skip your servers. That saves load, but you lose click counts and cannot change or expire the link. A 302 (found) sends every click to you, so analytics, edits and expiry work. Choose 302 when the product sells analytics.
What the interviewer listens for
Read-heavy: the redirect path is the one to optimize
Numbers: about 12 writes/s and 1,157 redirects/s on average
Code is the primary key; Redis in front of the database
301 is cached by browsers; 302 keeps analytics and edits working
Follow-ups the interviewer may ask
How do you support custom aliases? Hint: insert the alias as the code with the same unique constraint; reject it if taken.
How do you stop people using it to spread malware? Hint: check URLs against a blocklist on create and on a schedule, and rate limit link creation.
Common mistakes
Writing click analytics synchronously in the redirect path.
Choosing 301 for speed without realizing it breaks click counts and link edits.
A sequence: the payment service charges the PSP and gets no reply, marks the payment UNKNOWN and shows the customer 'processing'; after 30 seconds a status checker asks the PSP, learns the payment was captured, moves UNKNOWN to SUCCEEDED, and a later webhook finds the change already applied.
Why it is asked: Unknown outcomes are the hardest part of payments. Candidates who mark a timeout as failed cause double charges when the customer pays again.
You do not know, so record the payment as UNKNOWN, never as failed, and resolve it by asking the provider, retrying with the same idempotency key, waiting for the webhook, and finally reconciling against the provider's settlement report (the daily file of every payment it collected).
Why: the request may have failed before reaching the provider, or succeeded while the reply was lost. 'Failed' invites a second payment; 'succeeded' may ship unpaid goods.
State machine: CREATED -> AUTHORIZING -> SUCCEEDED or FAILED; AUTHORIZING -> UNKNOWN on a timeout; UNKNOWN -> SUCCEEDED or FAILED once resolved. Only forward moves are allowed, each as a conditional update such as 'set SUCCEEDED where status = UNKNOWN'. A success webhook for a payment already marked FAILED is an alarm for a human, not a silent overwrite.
Resolving UNKNOWN:
- A status job asks the provider about your payment ID at growing gaps (30 seconds, 2 minutes, 10 minutes, 1 hour).
- Retrying the charge with the same idempotency key is safe: the provider returns the original result.
- The webhook may settle it first; the conditional update makes the first answer win.
- The customer sees 'payment processing', not 'payment failed'.
Reconciliation: every day, match that file against your ledger by provider reference. Money the provider has but you do not show as paid: fix the state, then fulfill or refund. Payments you show as paid that the provider does not have: first allow for settlement lag (a capture, meaning money actually taken, often appears in the file a day or two later), confirm with the status API, then mark them failed. Alert on any unmatched money older than a day.
What the interviewer listens for
Timeout means unknown, not failed
Forward-only states with conditional updates
Resolve with status checks, same-key retries and webhooks
Daily reconciliation against the settlement file
Follow-ups the interviewer may ask
What if the provider has no status API? Hint: rely on the same-key retry and the webhook, and keep the payment UNKNOWN until reconciliation.
How do you stop the customer paying twice meanwhile? Hint: block a new attempt for the same order while one payment is UNKNOWN, and show its status.
Common mistakes
Treating a timeout as a failure and letting the customer retry with a new key.
Allowing any state to overwrite any other, so a late, wrong event can undo a success.
An enterprise view of a UPI payment: UPI apps such as PhonePe and Google Pay on the left, the payer's and payee's PSP banks, the NPCI switch in the middle that holds no money, and the remitter bank that debits and the beneficiary bank that credits on the right.
Why it is asked: UPI is the payment system most Indian candidates use every day, so interviewers at payment companies and banks expect you to know who owns each step and who actually holds the money.
In a UPI person-to-person payment, the payer's app sends a request through its PSP to the NPCI switch, NPCI asks the payer's bank to debit and the payee's bank to credit, and the result flows back to both apps.
The parties:
- UPI app (PhonePe, Google Pay, Paytm): the screen the user sees. It holds no money.
- PSP (payment service provider): a bank that connects the app to UPI and issues the user's VPA (virtual payment address, such as asha@bankx), which hides the account number.
- NPCI (National Payments Corporation of India): runs the UPI switch that routes messages between banks.
- Remitter bank: holds the payer's account and is debited.
- Beneficiary bank: holds the payee's account and is credited.
Asha pays Ravi Rs 500:
1. Asha enters ravi@banky. Through NPCI, Ravi's PSP returns his registered name, so Asha can check it.
2. Asha types her UPI PIN inside NPCI's common library in the app. It is encrypted on the phone.
3. Her PSP sends a pay request with a unique transaction ID to NPCI.
4. NPCI asks the remitter bank to debit. The bank checks the PIN, the balance and limits (Rs 1 lakh, Rs 100,000, for P2P; some banks set less), then debits.
5. NPCI asks the beneficiary bank to credit Ravi, then sends the final status to both PSPs.
Since 1 October 2025, P2P payments are push-only: only the payer can start them. NPCI stopped P2P collect requests (the payee asking for money) to cut fraud. Several times a day NPCI totals what each bank owes the others (settlement), and money moves between their accounts at the RBI, India's central bank.
What the interviewer listens for
The app holds no money; banks debit and credit, NPCI only switches messages
The payee's PSP resolves the VPA to an account and a name
The UPI PIN is encrypted on the phone and verified by the payer's bank
Debit first, then credit, then the final status to both PSPs
P2P payments are push-only since October 2025
Follow-ups the interviewer may ask
What happens if the beneficiary bank does not answer after the debit? Hint: the payment becomes pending (or deemed approved, treated as successful), status checks follow, and an amount that cannot be credited must be reversed by T+1 (the next day).
How can one app serve customers of hundreds of banks? Hint: the app talks only to its PSP; NPCI routes each message to the right bank, so the app never connects to the customer's bank directly.
Why does the payer see the payee's name before paying? Hint: the address check lets the payer catch a wrong VPA before any money moves.
Common mistakes
Saying the UPI app or NPCI holds the money; it stays in bank accounts the whole time.
Saying the app checks the UPI PIN; it is encrypted on the phone and checked by the payer's bank.
Describing a P2P collect request as a normal flow; it was stopped in October 2025.
Reference cards mapping three access patterns to their key design in the new store: order by ID on the base table, a customer's recent orders on a secondary index, and a restaurant's open orders on a sparse index, with joins sent to the warehouse.
Why it is asked: Moving between data models is harder than copying rows. Teams that copy MySQL tables one-to-one into DynamoDB find that half their queries have no key.
I would start from the access patterns, design the keys to serve each one, then migrate with change data capture and per-query shadow reads, and keep a way back until every query matches.
1. List the queries with their rates. For example: get an order by ID; a customer's orders, newest first; a restaurant's open orders today. Joins and ad hoc filters (one-off queries on any field) are not on the list for a reason.
2. Design keys from that list. Base table: partition key (the value DynamoDB hashes to place and find an item) ORDER#id. A secondary index with partition key CUSTOMER#id and sort key (the value items are ordered by inside one partition) by created time serves the customer list. A sparse index (one that holds only items that have the indexed attribute, here open orders), keyed by restaurant and date, serves the kitchen view. Data that MySQL joined (items, address) is copied into the order item, because DynamoDB has no joins.
3. Move the data: start CDC (reading MySQL's binary log) first, then backfill history in throttled batches. At 20,000 rows per second, 600 million / 20,000 = 30,000 seconds, about 8.3 hours; at 5,000, about 33.3 hours. Newer versions win over older rows.
4. Prove each query: shadow-read every access pattern from both stores and compare, until differences are zero or explained.
5. Move reads, then writes, behind flags, streaming changes back to MySQL so rollback is a flag flip.
What does not fit: reports that need joins or scans go to the data warehouse. A new query that no key serves needs a new index and a backfill, the real cost of this model.
What the interviewer listens for
Start from access patterns and their rates
Keys and indexes per query; copy into the order what MySQL joined (denormalize)
CDC before throttled backfill; newer versions win
Shadow-read and diff per access pattern
Joins and scans move to the warehouse
Follow-ups the interviewer may ask
How do you keep the copied address in orders correct? Hint: it should be a snapshot of the address used for that order, so it never needs updating.
What if one restaurant chain writes thousands of orders per second? Hint: one partition key takes about 1,000 writes per second, so split a hot key (RESTAURANT#ID#0..9) and read all parts; 100,000 orders for one customer is fine, because the sort key and a limit read only the newest page.
Common mistakes
Copying the MySQL tables one to one into DynamoDB and expecting the same queries to work.
Checking row counts only, instead of comparing the answers to each real query.
System Design and Distributed Systems Interview Pack
High-level and low-level design, distributed systems fundamentals, scaling and staff-level trade-offs.
200 questions and 268 diagrams, each with why it is asked, a full answer, what the interviewer listens for, follow-ups, common mistakes and a diagram. By Roni Das.