Scrivio Interview library

Classic system design problems

72 questions in 18 subtopics.

About this topic

Classic system design problems are the well-known products used to practise and test design skill: chat, ride-hailing, video streaming, booking, leaderboards, monitoring and more. Each one looks simple from the outside but hides one hard core, such as ordering messages, matching drivers, never overselling a seat or counting each click once. A good approach is the same every time: agree on the requirements and the numbers, define the API and data model, sketch the main components, then spend most of the time on the hard part and on how the system fails in production. The questions for each problem follow that path: a basic design with its API and data model, a deep dive into the hard part, a scale or failure scenario with real numbers, and a strategy or trade-off decision of the kind senior leaders make.

Chat and messaging service

A chat service delivers short messages between people and groups in near real time, across phones and browsers, and keeps history for every device. Before answering, think about long-lived connections, what happens when the recipient is offline or has several devices, how order is defined inside a conversation, and how the system behaves when many connections drop and return at once.

DesignFoundations7 min read

A chat service lets people send one-to-one and small group messages from phones and browsers, shows sent, delivered and read states, and keeps history so a user who signs in on a new device sees past conversations.

Define the API, the main data model and the high-level components of a chat service for 50 million daily users who send about 40 messages each per day, and explain how a message reaches a recipient who is online and one who is offline.
DebuggingIntermediate7 min read

A group chat service builds message ids from the sending server's clock plus a random suffix, and clients sort by id. Users with a phone and a laptop report messages out of order in busy groups, and some messages show twice on the second device after it reconnects.

What causes both symptoms, and how would you design message ordering and multi-device sync so every device shows the same order with no gaps or duplicates?
ScenarioAdvanced7 min read

A chat platform holds 6 million concurrent WebSocket connections on 300 gateway pods. A routine deploy restarted pods in batches of 30; each batch dropped about 600,000 clients, which reconnected and synced at once, and delivery latency rose from 200 ms to 90 seconds for everyone.

Explain why a routine gateway deploy became a platform-wide incident, and what you would change in the gateways, the clients and the sync path so restarts and gateway failures stay invisible to users.
LeadershipPrincipal7 min read

A messaging product stores messages in a form the server can read, which powers server-side search, spam detection and moderation. Privacy-minded customers and regulators now push for end-to-end encryption, where only the users' devices hold the keys.

As the senior technical leader, how do you decide whether and how to move the messaging product to end-to-end encryption, and which features, operations and risks change?

Ride-hailing and location tracking

A ride-hailing service connects riders with nearby drivers whose positions change every few seconds. The trip itself is a small, durable state machine, while location updates are a huge, loss-tolerant stream. Understand the difference between those two kinds of data, why straight-line distance is a poor guide to arrival time, and why demand can jump tenfold in one city within a minute.

DesignFoundations6 min read

A ride-hailing service matches riders with nearby drivers. Driver apps send their position every few seconds; a rider requests a trip, a driver accepts, the trip moves through pickup and drop-off, and the fare is charged at the end.

Define the main APIs, the trip data model and the trip states for a ride-hailing service, and outline the services involved from ride request to payment.
DebuggingIntermediate7 min read

A ride-hailing dispatch service picks the nearest free driver for each request and sends that driver an offer. At evening peak, logs show one driver receiving two offers within 300 ms, some riders wait 40 seconds while drivers decline, and a few drivers end up assigned to two trips.

How would you redesign dispatch so a driver is never assigned two trips, declined offers do not stall riders, and matching uses travel time rather than straight-line distance?
ScenarioAdvanced6 min read

A ride-hailing service runs one dispatch and location stack per region. On New Year's Eve at 00:00, trip requests in one large city jumped from 1,500 to 14,000 per minute, location update lag reached 25 seconds, and riders were matched with drivers who had already left the area.

What failed during the New Year's Eve spike, and how do you prepare dispatch, location ingestion and pricing for a known tenfold spike in one city?
LeadershipPrincipal6 min read

A ride-hailing company pays a mapping vendor per routing and ETA call. At 30 million calls a day the bill is a large share of infrastructure cost, and ETA errors in some cities cause poor matches and fare disputes.

As the senior technical leader, how do you decide whether to build an in-house routing and ETA platform, keep the mapping vendor, or combine the two?

Video streaming platform

A video streaming platform turns uploaded files into many versions at different qualities and serves them to viewers on very different networks and devices. Almost all bytes come from a content delivery network. Understand the processing pipeline, how players adapt to bandwidth, why live events load the system differently from on-demand viewing, and how bandwidth and compute dominate cost.

DesignFoundations8 min read

A video streaming platform lets creators upload videos and viewers watch them on phones, TVs and browsers over networks of very different speeds. Uploads must be processed before playback, and almost all viewing traffic is served from a content delivery network.

Describe the upload, processing and playback paths of a video streaming platform with their API and data model, and explain how adaptive bitrate streaming keeps playback going when a viewer's bandwidth drops.
ScenarioIntermediate7 min read

A video platform receives 500 hours of uploads per minute at peak. One worker transcodes each upload from start to end; a two-hour 4K upload takes 6 hours, the queue holds 40,000 jobs on busy days, and creators complain that short clips wait behind long films.

How would you redesign the transcoding pipeline so short videos are ready in minutes, long ones finish in reasonable time, and failed work is retried without starting over?
ScenarioAdvanced7 min read

A streaming platform broadcasts a live final to 4 million concurrent viewers. Ten minutes in, the CDN hit ratio for live manifests dropped, origin requests jumped from 20,000 to 900,000 per second, origins returned 503 errors and players stalled in several countries.

Why is live streaming harder on the CDN and origin than on-demand video, what likely caused this collapse, and how do you design live delivery to survive it?
LeadershipPrincipal6 min read

A video platform's CDN bill has become its largest cost. A newer codec could cut bitrate by about 30 percent at the same quality, but encoding with it costs several times more compute, and older devices cannot decode it.

As the senior technical leader, how do you decide on adopting the newer codec, and on building your own delivery network versus staying on commercial CDNs?

File storage and sync

A file storage and sync service keeps the same folders up to date across several devices and shared users, with version history. Files can be huge and devices are often offline. Think about how files are split and stored, how a device learns what changed since it last looked, what happens when two people change the same file, and how one client bug can multiply server load.

DesignFoundations7 min read

A file storage and sync service keeps a folder in step across a person's laptop, phone and the web, lets people share folders, and keeps earlier versions of each file. Files range from a few bytes to tens of gigabytes.

Design the API and data model of a file storage and sync service, including how large files are uploaded and how a second device learns that a file changed.
DebuggingIntermediate6 min read

Two people edit the same spreadsheet in a shared folder while one of them is on a plane. When the laptop reconnects, its sync client uploads its version, the other person's changes from the last three hours vanish, and support tickets about lost work grow every month.

How should the sync protocol detect and handle conflicting edits so no work is lost, and how can it avoid re-uploading a whole 2 GB file when only a few bytes changed?
ScenarioAdvanced6 min read

A file sync service has 80 million devices. A client release reset each device's sync cursor, so the 2 million devices that updated in the first hour each asked for a full file listing. Metadata database CPU reached 100 percent and sync stalled for every user for four hours.

How do you contain this sync incident while it runs, and what changes in the server and in client release practice stop one client bug from overloading the metadata tier again?
LeadershipPrincipal7 min read

A file storage company keeps 400 PB in a public cloud object store. Storage is now its largest cost and grows 40 percent a year, and finance asks whether running its own storage would be cheaper.

As the senior technical leader, how do you evaluate moving bulk storage to your own data centers with erasure coding, against staying in the cloud and using cheaper storage tiers?

Web crawler

A web crawler downloads pages, follows their links and repeats at a scale of billions of pages. The difficulty is less in fetching than in choosing what to fetch next, being polite to each website, avoiding duplicate and endless URL spaces, and deciding when to come back to a page. Respecting site owners' rules is part of the design, not an extra.

DesignFoundations7 min read

A web crawler starts from seed URLs, downloads pages, extracts their links and keeps going, feeding a search index or a dataset. It must respect each site's robots.txt rules and must not load any one site too heavily.

Outline the components of a web crawler that fetches 1 billion pages a month, the data it keeps for each URL, and how a URL moves from discovery to a stored page.
DesignIntermediate7 min read

A crawler's fetchers pull URLs from one shared priority queue. A large news site complained after receiving 300 requests per second from it, yet overall crawl throughput is only a third of target because fetchers sit waiting on slow hosts.

Design a URL frontier that enforces politeness per host while keeping all fetchers busy, and explain where priority and recrawl scheduling fit in.
ScenarioAdvanced6 min read

A crawler fleet of 200 nodes fetches 5,000 pages per second. In one week its frontier grew from 2 billion to 9 billion URLs, half of the new URLs came from a few hundred hosts, and the share of fetches that found useful new pages fell from 40 percent to 6 percent.

What is probably happening to the frontier, how do you confirm it, and how do you change the crawler so it stops wasting its fetch budget?
LeadershipPrincipal6 min read

A company runs a large crawler to build search and analytics datasets. Site owners increasingly block unknown crawlers, some ask to be left out of AI training data, and the legal team worries about terms of service, copyright and personal data.

As the senior technical leader, how do you set crawling policy and strategy so the dataset stays useful while the company remains a welcome and lawful visitor?

Search autocomplete

Search autocomplete suggests completions on almost every keystroke, so answers must arrive in a few tens of milliseconds at very high request rates. Think about how suggestions are chosen and ranked from past searches, how they are served from memory and caches, how fresh topics get in quickly, and why every suggestion shown needs a safety check.

DesignFoundations6 min read

Search autocomplete suggests completions while a person types in a search box. The whole round trip should take about 100 ms, so the server has a few tens of milliseconds, and requests arrive on almost every keystroke.

Design the API, data model and serving path of an autocomplete service that returns the top 10 suggestions for a prefix at 20,000 requests per second.
DesignIntermediate6 min read

An autocomplete service rebuilds its suggestions once a day from 30 days of search logs. When a major news event breaks, people type its name for hours, but the suggestions keep showing last month's popular queries.

How do you build top-k suggestions per prefix from billions of logged queries, and add a fresh layer so trending queries appear within minutes?
DebuggingAdvanced6 min read

An autocomplete service handles 60,000 requests per second, 85 percent answered by an edge cache. After a release that changed how prefixes are normalised, the edge hit ratio fell to 30 percent, origin p99 rose from 15 ms to 220 ms, and suggestions arrived after people had finished typing.

Explain how a normalisation change could cause this, how you recover during the incident, and how such changes should be released next time.
LeadershipPrincipal5 min read

A product team wants autocomplete personalised from each person's search history and location, plus a generated answer inside the suggestion list. Privacy and legal teams worry about exposing sensitive searches, and today's system is shared and anonymous.

As the senior technical leader, how do you weigh personalised and generated suggestions against privacy, safety and cost, and what would you build first?

Distributed key-value store

A distributed key-value store spreads simple get and put operations over many machines and keeps several copies of every value. Understand how keys are placed and moved when machines are added, what different consistency settings promise and do not promise to a client, how each node stores data on disk, and what operating such a store at high disk usage involves.

DesignFoundations7 min read

A distributed key-value store keeps values under keys across many machines and offers simple get and put calls with low latency. It must keep working when machines fail and grow by adding machines, which forces choices about partitioning, replication and consistency.

Design the API and the main mechanisms of a distributed key-value store that holds 50 TB and serves 1 million operations per second: how keys are placed, how they are replicated, and what a client sees when it reads after a write.
InternalsIntermediate6 min read

A leaderless key-value store replicates each key three times and two services use it for counters and account limits with read-modify-write at QUORUM. Audits find about 0.02 percent of updates lost, although every write was acknowledged by two replicas.

Why do quorum reads and writes not prevent these lost updates, and how would you add a safe compare-and-set operation to the store?
ScenarioAdvanced6 min read

A 60-node key-value cluster reached 82 percent disk use, so the team added 20 nodes at once. Rebalancing streamed data at full speed, p99 read latency rose from 5 ms to 400 ms, and two old nodes ran out of disk during compaction while still sending data.

What went wrong with this expansion, and how should capacity planning and rebalancing work so the cluster grows without hurting latency or running out of space?
LeadershipPrincipal6 min read

A company runs a home-grown key-value store built eight years ago. It holds 2 PB for 300 services, and the team that knows it has shrunk to four engineers. Incidents in it are rare but long, and hiring for it is hard.

As the senior technical leader, how do you decide whether to keep investing in the home-grown store, migrate to an open-source store, or move to a managed cloud service?

Distributed message queue

A distributed message queue stores messages from producers until consumers process them, smoothing bursts and decoupling services. Designing one means choosing between a retained log read by offset and a queue with per-message acknowledgement, deciding when a message counts as safely stored, and keeping many tenants from harming each other on shared hardware.

DesignFoundations7 min read

A distributed message queue lets producer services hand off messages that consumer services process later, smoothing bursts and decoupling teams. Designing one means choosing how messages are stored, acknowledged and redelivered when consumers fail.

Design the API, storage model and delivery guarantees of a distributed message queue that accepts 200,000 messages per second, and compare a log with consumer offsets to a queue with per-message acknowledgement.
InternalsIntermediate6 min read

A team built a task queue on a partitioned log. One failing task is retried for 30 minutes and blocks everything behind it in its partition, some tasks must run 15 minutes later, and slow tasks time out and are processed twice.

How would you add per-message acknowledgement, redelivery with backoff and delayed delivery on top of a log-based queue without losing its throughput?
ScenarioAdvanced6 min read

A shared message queue cluster serves 120 teams. One team's producer bug sent 30 times its normal volume for 6 hours; broker disks reached 95 percent, produce latency for every team rose from 5 ms to 2 seconds, and two brokers went offline when their disks filled.

How do you recover the shared cluster, and what isolation would you build so one tenant's surge cannot take the others down?
LeadershipPrincipal5 min read

A company runs three messaging systems: a self-managed log-based cluster, a traditional broker for task queues and a cloud provider's queue service. Platform cost and on-call load are high, and teams keep asking which one to use.

As the senior technical leader, would you consolidate on one messaging technology, keep several with clear rules, or move to managed services, and how do you decide?

Ticket booking with seat holds

A ticket booking service sells specific seats that must never be sold twice. Buyers hold seats for a few minutes while they pay, and popular events bring hundreds of thousands of buyers at the same moment. Think about how a hold is placed atomically, what happens when payment and hold expiry overlap, and how fairness and bots shape the design.

CodingFoundations8 min read

A ticket booking service sells reserved seats for concerts and sports. A buyer picks seats, which are held for a few minutes while they pay; if payment does not finish in time, the seats go back on sale.

Design the API and data model for seat selection with timed holds, and write the SQL statement that places a hold on one seat so that two buyers can never hold the same seat.
DebuggingIntermediate6 min read

A booking service holds seats for 8 minutes. Payment providers sometimes confirm after 9 to 12 minutes, by which time the seats have been resold; last month the same seat was sold twice 140 times, each needing a refund and an apology.

How do you make hold expiry and payment completion safe together, so no seat is sold twice and no buyer is charged for seats they lost?
ScenarioAdvanced6 min read

A 60,000-seat stadium tour goes on sale at 10:00 with 900,000 people in the waiting room. In the first on-sale, seat-map requests reached 150,000 per second, hold attempts on popular sections failed 80 percent of the time, and row locks piled up in the seats table.

How would you redesign seat selection and inventory for the next on-sale so throughput stays high, contention stays low, and buyers get seats instead of errors?
LeadershipPrincipal6 min read

A ticketing company sees bots buy a large share of popular events within seconds, and the tickets reappear on resale sites at several times face value. Artists and regulators criticise the company, while resale also brings fee revenue.

As the senior technical leader, what strategy would you propose for fair access to high-demand events, and how do you weigh fairness, revenue and engineering cost?

Flash sale

A flash sale offers a small stock of discounted items from an exact moment, so traffic rises from almost nothing to an enormous peak in seconds and most attempts must be turned away. Understand where requests can be rejected cheaply, how stock is counted without overselling, how unpaid orders return stock, and how failures in fast in-memory components affect correctness.

DesignFoundations6 min read

A flash sale sells a limited stock of discounted items from an exact moment, so traffic jumps from almost nothing to hundreds of times normal within seconds and most buyers leave empty-handed. The design must stay up, never oversell and decide quickly who wins.

Design the request path, API and data model of a flash sale for 10,000 units with 2 million expected visitors, from the product page to a confirmed order.
CodingIntermediate7 min read

A flash sale decrements stock in Redis and creates orders asynchronously. It showed sold out after 40 seconds, yet afterwards 230 of the 10,000 units were unsold: some winners never paid, some orders failed, and some users had won twice from two browser tabs.

Design the stock deduction step as one atomic Redis operation that also enforces one unit per user, and explain how unpaid and failed orders return their units without overselling.
ScenarioAdvanced7 min read

During a flash sale the Redis primary holding the stock counter failed 25 seconds in. A replica was promoted, but asynchronous replication had not copied the last few thousand decrements, and 1,800 more orders were accepted than units existed.

Why did the Redis failover cause overselling, how do you handle the 1,800 extra orders now, and how do you design the stock gate so a failover cannot oversell again?
LeadershipPrincipal6 min read

Marketing wants weekly flash sales because they bring traffic and press. Each sale has needed weeks of preparation by several teams, regular checkout slowed for all customers during the last two, and support handles complaints from people who never had a chance.

As the senior technical leader, how do you decide whether to build a dedicated flash-sale platform, harden the main commerce stack, or change how the sales work?

Game leaderboard

A game leaderboard ranks players by score and shows the top players and each player's own position, often per season, region or group of friends. Before answering, separate the record of trusted results from the fast ranking structure built from it, and think about cheating, ties, friend rankings and what changes when rankings decide prizes.

DesignFoundations6 min read

A game leaderboard ranks players by score so they can see the top players and their own position. Scores come from matches that must be trusted, boards may be global, regional or per season, and ranks should update within seconds of a match ending.

Design the API and data flow of a leaderboard service from the end of a match to an updated rank, including where the record of truth lives and how scores are validated.
DesignIntermediate6 min read

A game has 80 million players with up to 500 friends each. Players open the friends leaderboard far more often than the global one, and today each view reads every friend's score from the database, taking 600 ms at p99.

How would you design the friends leaderboard so it opens in under 50 ms, and how do score changes reach it?
ScenarioAdvanced6 min read

A tournament leaderboard lives in an in-memory store with an asynchronous replica. Two minutes before the tournament ended the primary failed; the promoted replica was missing 40 seconds of score updates, and the final standings that decided cash prizes were wrong for 3,000 players.

How do you settle this tournament fairly, and how should a leaderboard that decides prizes be designed so its standings survive failures?
LeadershipPrincipal5 min read

A game studio plans tournaments with real-money prizes in many countries. Its leaderboard was built for casual rankings: fast, approximate during peaks and tolerant of a little cheating.

As the senior technical leader, what must change in technology, process and organisation before leaderboards decide money, and in what order?

Metrics and monitoring system

A metrics and monitoring system collects numeric time series from every service and host, stores them compactly, draws dashboards and raises alerts. Understand how series are identified by names and labels, why the number of distinct series matters more than raw volume, how alerting works, and why monitoring must keep working during the outages it is meant to detect.

DesignFoundations7 min read

A metrics and monitoring system collects numbers such as request rates, error counts and latency from thousands of services and hosts, stores them as time series, draws dashboards and fires alerts when something goes wrong.

Design the data model, collection path, storage and query API of a metrics system for 20,000 hosts that each expose 2,000 series every 15 seconds.
DebuggingIntermediate7 min read

A metrics cluster that held 8 million active series grew to 45 million in two days. Ingesters ran out of memory and restarted in a loop, dashboards showed gaps, and the growth came from one service's new metric label.

How do you find the cause of the series explosion, stop it, and keep label cardinality from taking down the metrics system again?
ScenarioAdvanced5 min read

During a regional network outage, a company's metrics and alerting stack, hosted in that same region, went down with everything else. On-call engineers learned of the outage from customers 25 minutes later, and dashboards were blank while they worked.

How do you design monitoring so it keeps working, or at least warns someone, during the failures it exists to catch?
LeadershipPrincipal6 min read

A company's observability spending rose from 4 to 14 percent of its infrastructure bill in two years. Teams send metrics, logs and traces to a commercial vendor that bills by volume, and finance asks engineering for a plan.

As the senior technical leader, how do you decide between optimising usage with the vendor, building an in-house observability stack on open-source tools, or a mix?

Log aggregation

A log aggregation system collects log lines from thousands of processes into searchable storage for debugging, alerting and audits. Volume is large, bursty and mostly never read, and it peaks during incidents. Think about the path from agent to storage, what to index and what to scan, retention tiers, personal data in logs and the cost of keeping everything.

DesignFoundations6 min read

A log aggregation system gathers log lines from thousands of services and hosts into one place, so engineers can search them during incidents, alert on them and keep them for audits. Log volume is large and bursty, and most of it is never read.

Design the pipeline, data model and search API of a log aggregation system that ingests 2 TB of logs per day from 5,000 pods.
DesignIntermediate6 min read

A log platform indexes every field of every log line in a search cluster. Ingest has grown to 10 TB a day, the cluster needs 300 nodes, indexing falls 20 minutes behind at peak, and query logs show most data is never searched.

How would you redesign log storage and indexing so cost grows more slowly than volume, while engineers can still find the logs they need during an incident within seconds?
ScenarioAdvanced6 min read

During a database outage, every service logged a stack trace for each failed request. Log volume went from 25 MB/s to 400 MB/s, the log pipeline fell 40 minutes behind, and engineers investigating the outage could not see current logs.

Why did the log pipeline fail exactly when it was most needed, and how do you design it to stay useful during log storms?
LeadershipPrincipal6 min read

Logs are the largest part of a company's observability bill. Security wants every log kept for a year for investigations, privacy wants personal data minimised and deletable on request, and engineering wants fast search over 30 days.

As the senior technical leader, how do you set a logging policy that balances cost, security, privacy and engineering needs?

Ad click aggregation

An ad click aggregation system counts clicks and impressions per ad and time window for dashboards, budget pacing and billing. Money depends on the numbers, so each valid click must count exactly once even when events arrive late or processing restarts. Understand event time, duplicates, how raw data supports corrections, and how real-time and final numbers relate.

DesignFoundations6 min read

An ad click aggregation system counts clicks and impressions per ad, campaign and time window, so advertisers see results in near real time and are billed correctly. It receives billions of events a day and must count each valid click once.

Design the ingestion, aggregation and query path of an ad click aggregation system for 10 billion clicks a day, with per-minute counts per ad available within a minute.
InternalsIntermediate7 min read

An ad click stream job counts clicks per ad per minute using processing-time windows. Mobile apps send clicks in batches when they regain signal, some 30 minutes late, and when the job restarts after a crash some minutes are counted twice.

How do you make the per-minute click counts correct despite late events and job restarts, and which trade-off between latency and completeness do you choose?
ScenarioAdvanced6 min read

A change to an ad click aggregation job double-counted clicks for one ad format for 6 hours before anyone noticed. Advertisers had already seen inflated numbers, and some budgets ran out early because pacing used those counts.

How do you correct the data and the money, and how should the aggregation system be built so such errors are caught in minutes and repaired without guesswork?
LeadershipPrincipal5 min read

An ad platform runs separate streaming and batch pipelines for click counts. Streaming numbers feed dashboards and budget pacing, batch numbers feed invoices, and the two differ by up to 2 percent, which advertisers notice and dispute.

As the senior technical leader, do you unify on one click-counting pipeline or keep two, and what accuracy promises do you make to advertisers?

Nearby places search

A nearby places search returns points of interest around a location, filtered and ranked by distance, rating and relevance. Place data changes slowly while searches arrive constantly. Understand how locations are turned into searchable cells, why searches near cell edges and in dense cities need care, and how the index stays fresh as places open, close and change.

DesignFoundations7 min read

A nearby places search finds restaurants, shops and other points of interest around a location, such as cafes within 2 km, ranked by distance, rating and relevance. Place data changes slowly while searches arrive constantly from mobile apps.

Design the API, data model and spatial index of a nearby places search for 200 million places and 50,000 searches per second.
InternalsIntermediate7 min read

Places can be indexed by geohash strings, by quadtrees that split busy areas into smaller cells, or by hierarchical cells on the sphere such as S2 or H3. Searches near a cell edge, and in dense cities versus open countryside, behave differently in each.

Compare geohash, quadtree and S2 or H3 cells for nearby search, explaining the cell-edge problem and how each copes with uneven density.
ScenarioAdvanced7 min read

A places search rebuilds its spatial index every night from the main database. With 200 million places the rebuild now takes 9 hours and sometimes is not finished by morning, and business owners complain that new places and changed opening hours take a day to appear.

How do you move the places index from nightly rebuilds to near-real-time updates, and how do you shard and roll out the new index safely?
LeadershipPrincipal6 min read

A local search company maintains its own place data, collected from business owners and users, and spends heavily on data quality. A data provider offers licensed place data for 40 countries, and the product team wants to launch in 15 new countries within a year.

As the senior technical leader, how do you decide between licensing place data, building your own collection, or combining both, and which risks do you manage?

Collaborative document editing

A collaborative editor lets many people change the same document at once and see each other's edits almost instantly. Concurrent edits to the same text must end in the same result on every screen. Think about how edits are represented and ordered, how history and snapshots are stored, how presence is shared, and what happens to edits when a server or network fails.

DesignFoundations7 min read

A collaborative document editor lets several people type in the same document at once and see each other's changes and cursors within a fraction of a second, while keeping full history and surviving brief network drops.

Design the main components, API and data model of a collaborative document editor for documents with up to 100 simultaneous editors.
InternalsIntermediate7 min read

Two people edit the same spot in a shared document at the same moment: one inserts 'cat' at position 10 while the other deletes characters 8 to 12. Applied naively in different orders, their two copies of the document end up different.

How do operational transformation and sequence CRDTs each make both copies converge, and what does each approach cost in a real text editor?
ScenarioAdvanced6 min read

A company-wide announcement document was opened by 3,000 people, 400 of them adding comments and edits at once. The session server owning the document hit 100 percent CPU, edits lagged by 20 seconds, and after it restarted some users had lost about 30 seconds of edits.

Why did one popular document overload its session server and lose edits, and how do you design for hot documents and session-server failures?
LeadershipPrincipal6 min read

A document product built on a central server with operational transformation now gets requests for full offline editing on laptops and phones and for end-to-end encrypted documents. The core team proposes rewriting the sync engine on CRDTs.

As the senior technical leader, how do you decide whether to rewrite the collaboration engine, and how would you reduce the risk if you go ahead?

Social graph and followers

A social graph stores who follows whom for hundreds of millions of people, with a few accounts followed by tens of millions. Profiles, feeds and permission checks all read it constantly. Understand which queries must be fast, why edges are often stored in both directions, how counts stay correct, and how a graph this large is moved or extended.

DesignFoundations7 min read

A social graph records who follows whom. Profile pages show follower and following counts and lists, the feed needs each person's followees, and the app often asks whether one person follows another. A few accounts have tens of millions of followers.

Design the API and data model of a follow service for 500 million users who follow 200 accounts on average, covering follow, unfollow, lists, counts and the does-A-follow-B check.
DebuggingIntermediate6 min read

A follow service writes each follow to a following table and a followers table on different shards, then bumps two counters. After a year, 0.5 percent of users have counts that do not match their lists, some edges exist in one direction only, and writes for one celebrity time out.

Explain how each of these follow-graph problems arises, and how you would redesign the write path and storage to fix them.
ScenarioAdvanced6 min read

A social app keeps 40 billion follow edges in a MySQL cluster sharded by hand on user id ranges. Several shards are at 90 percent disk, and the team must move to a new horizontally partitioned store while the app handles 30,000 follow and unfollow writes per second.

Plan the migration of the follow graph to the new store with no downtime and no lost or resurrected edges.
LeadershipPrincipal6 min read

Product wants friend suggestions, mutual-follow counts and multi-hop queries such as people you follow who follow a given page. One team proposes moving the whole follow graph into a graph database; another wants to keep the partitioned edge store and add offline graph jobs.

As the senior technical leader, how do you decide which graph storage strategy to adopt for these features?

Stock exchange order matching

A stock exchange matching engine pairs buy and sell orders by strict, published priority rules, with latency measured in microseconds and no tolerance for lost or reordered orders. Before answering, understand the order book and common order types, why determinism matters for fairness and recovery, and what a sudden burst of orders at market open does to the system.

DesignFoundations7 min read

A stock exchange matching engine receives buy and sell orders and matches them by strict rules, usually price-time priority. It must be fair, deterministic and very fast, and every order and trade must be recorded exactly.

Describe the order book data structure, the main order types and the API, and walk through how a new limit order is matched under price-time priority.
InternalsIntermediate6 min read

A matching engine must handle hundreds of thousands of orders per second with latency in microseconds, produce the same result for the same input every time, and recover after a crash without losing or reordering a single order.

Why are matching engines usually single-threaded per group of symbols, and how do a sequencer, an event journal and replicas provide low latency, determinism and recovery?
ScenarioAdvanced7 min read

At market open a trading venue gets 2 million order messages in the first second, ten times normal. Acknowledgement latency for some clients rose from 50 microseconds to 80 ms, and a primary engine failed; the backup took over, but two clients reported fills they could not reconcile.

How should the venue handle the opening burst and the engine failover so latency stays predictable and every client's view of its orders stays exact?
LeadershipPrincipal6 min read

An exchange operator is building a new venue for a newer asset class. Teams debate running the matching engine in a colocation data center on specialised hardware or in a public cloud, and how much to sell low-latency access to trading firms.

As the senior technical leader, how do you weigh latency, fairness, cost and regulation when choosing where and how to run the new venue's matching engine?