Skip to content
Tutorials Center
My learning

Topics

Lesson 57 of 77 ยท DevOps, Tools and System Design

System Design Case Studies: Dropbox, Netflix, Uber, BookMyShow and Messenger

Walk through five classic system design interview questions: Dropbox, Netflix, Uber, BookMyShow and Messenger, with requirements, storage, scaling and runnable models.

By now you know the building blocks: load balancers, caches, queues, databases and CDNs (System Design: The Building Blocks) and a few patterns (Rate Limiters, Feeds and Chat). A case-study question asks you to assemble them for a named product. The skill is not to remember a diagram. It is to pick the one or two hard problems in each product and say what you would do about them.

Each case below follows the same order: requirements, the core hard problem, the storage and data flow, and the scaling or failure issues. The numbers are interview-style estimates, not measurements. The runnable blocks (Node.js in the page runner) are small models of the hard problem, not the real systems.

The hard problem in each case

Dropbox Sync large files efficiently.
Netflix Stream smoothly to any device.
Uber Find nearby drivers in real time.
BookMyShow Never sell a seat twice.

Messenger adds ordering, delivery and presence at huge scale.

1 / 2

Design Dropbox (file storage and sync)

Requirements. Upload, download and share files; keep folders in sync across a user's devices; handle large files and flaky networks; keep version history. Say the scale: 500 million users, 100 million active, each with a few GB, means exabytes in total, with a read-heavy but write-spiky pattern.

Core problem: do not re-upload a whole file for a small change. Split every file into chunks (typically about 4 MB), hash each chunk (SHA-256) and treat the hash as the chunk's identity. The client asks the server which hashes it lacks and uploads only those. That gives three things at once: delta sync (editing one part uploads one chunk), resumable uploads (the client resumes at the first missing chunk) and deduplication (two users, or two versions, with the same chunk store it once).

Data model. Keep metadata apart from content. A metadata database (a sharded relational store, because file trees need transactions: rename, move, share) holds users, files, folders, versions and the ordered list of chunk hashes per version. The content lives in an object store (S3-like), addressed by chunk hash.

flowchart LR
    C["Client app<br/>watches folder, chunks, hashes"] -->|"1. chunk list"| M["Metadata service"]
    M -->|"2. missing chunks"| C
    C -->|"3. upload chunks"| B["Block service"]
    B --> O[("Object store")]
    M --> D[("Metadata DB")]
    M -->|"4. change event"| Q["Notification service"]
    Q -->|"long poll / push"| C2["Other devices"]

Devices learn about changes through a notification channel, then pull the new chunk list and download only the chunks they lack.

The next block models chunking. With fixed-size chunks, changing one byte in place re-uploads one chunk, but inserting a byte shifts every later chunk boundary, so everything after it looks new. That is why real systems use content-defined chunking (boundaries chosen by a rolling hash, so they move with the content).

Node.js Model: fixed-size chunks, hashes and deduplication

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Scaling and failures. Shard metadata by user ID; cache hot metadata; replicate object storage across zones; use a message queue between "chunk stored" and "notify other devices"; keep a per-file version vector or last-writer-wins rule and write a conflicted copy instead of silently overwriting when two devices edit offline. Sharing and permissions are checked in the metadata service, never in the client.

Design Netflix (video streaming)

Requirements. Play video on demand with fast start and no buffering on phones, TVs and browsers; huge catalog; recommendations; global audience. Reading is the whole game: uploads are rare (the studio uploads a title once) but playback is constant.

Core problem: deliver bytes close to the viewer, at a quality the network can sustain.

  1. Transcoding pipeline. The uploaded master file is split into small segments (a few seconds) and encoded in parallel into a bitrate ladder: many resolutions and bitrates (for example 235 kbps up to 16 Mbps) and several codecs and audio tracks. This is an offline, queue-driven, massively parallel job.
  2. Adaptive bitrate streaming (HLS or DASH). The player downloads a manifest listing every segment at every quality, then fetches one segment at a time and picks the quality of the next segment from the measured throughput and the buffer level. Network slows: it steps down instead of stalling.
  3. CDN placement. Segments are served from edge caches inside ISP networks (Netflix calls its boxes Open Connect), pre-filled overnight with titles predicted to be popular in that region. A request goes to the nearest server holding the title; the origin is only for misses.

The control plane (login, browse, recommendations, billing, picking the right CDN node) runs in the cloud as microservices; the data plane (the video bytes) never touches it, which is why the catalog can stay up even when the recommendation service is slow. Design the control plane for resilience (timeouts, fallbacks to a default row of titles) and the data plane for bandwidth.

Node.js Model: adaptive bitrate selection

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Read the output: the first bad sample (900 kbps) does not drop the quality, because the smoothed estimate is still high; the sustained slowdown does, and a nearly empty buffer forces the lowest rung at once.

Scaling. Cache by segment URL (immutable, so cache-forever), shard the metadata (titles, viewing history) by user, use a wide-column or key-value store for viewing history (write-heavy, simple access by user), and precompute recommendations offline and store them for fast reads. Failure testing (killing instances on purpose) is part of Netflix's culture; mention graceful degradation.

Requirements. Riders request a ride; the system finds nearby available drivers, offers the trip, tracks both in real time, calculates the fare and takes payment. Drivers send their location every few seconds, so location updates are the dominant traffic: 1 million drivers at one update per 4 seconds is about 250,000 writes per second.

Core problem: "find the nearest drivers" without scanning every driver. A normal index on latitude and longitude does not answer a nearby query well. Use a spatial index: divide the map into cells (a grid, a geohash, Google S2 or Uber's H3 hexagons), keep a map from cell to the drivers inside it, and for a request look up the rider's cell plus the ring of neighboring cells, then rank by exact distance or by ETA from a routing service.

Driver locations are ephemeral and change constantly, so keep them in memory (an in-memory store or a sharded service, sharded by city or cell) with a short TTL and write them to disk only occasionally. Trips, payments and ratings are durable and go to a transactional database.

Node.js Model: a grid index versus scanning every driver

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

One caveat to mention: if the nearest driver is across a cell boundary and the neighbor ring is too small, a sparse area can return too few results. Real systems widen the ring step by step until they have enough candidates.

Matching and consistency. Dispatch offers a trip to one driver (or a few) at a time with a timeout, and the offer must be idempotent and exclusive: a driver must not be given two trips. Use a state machine for the trip (requested, offered, accepted, picked up, completed) stored in a transactional database, with a lock or compare-and-set on the driver's state. Use WebSockets or push notifications for real-time position and trip updates. Surge pricing is a periodic aggregation per cell of demand versus supply, computed in a streaming job.

Design BookMyShow (ticket booking)

Requirements. Browse cities, movies and shows; view a seat map; select seats; pay; receive a ticket. Traffic is spiky (a blockbuster opens booking at noon) and the one rule that must never break is no double booking: two people cannot buy the same seat.

Core problem: concurrency on a small, hot set of rows. Reading the catalog scales with caches and CDNs. The seat map for a popular show is a write hotspot. The standard solution is a temporary hold:

  1. When a user selects seats, the system tries to place a hold with an expiry (for example 5 to 10 minutes) using an atomic operation: a conditional UPDATE ... WHERE status = 'available', a database row lock (SELECT ... FOR UPDATE), or SET NX with a TTL in Redis. If the seat is already held or sold, the attempt fails immediately.
  2. The user pays within the hold window. On payment success the seat becomes booked in the transactional database, only if the hold still belongs to that user.
  3. If the user abandons the page or the timer runs out, the hold expires and the seat becomes available again (a TTL does this for free, or a background sweeper does).

The payment step is a distributed workflow: charge the card, then confirm the booking. If the charge succeeds but the confirmation fails, you need a compensating action (refund) or a saga, and idempotency keys so a retried request never charges twice (see System Design: Rate Limiters, Feeds and Chat).

Node.js Model: seat holds with expiry and no double booking

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Scaling. Put the catalog and show listings behind a cache and CDN; keep the seat-map reads in a fast cache with short TTLs (the source of truth for holds remains the database or Redis); partition by show; put a virtual waiting room (queue) in front of a hot release so only a controlled number of users reach the booking flow; and rate-limit bots.

Design Messenger (chat at scale)

The basics of one-to-one chat, WebSockets and offline delivery are in Rate Limiters, Feeds and Chat. A full Messenger design adds these topics:

  • Connections. Hundreds of millions of persistent WebSocket connections are held by a fleet of gateway servers. A presence/session store (user to gateway mapping) lets any service find which gateway to push through.
  • Message flow. The sender's gateway writes the message to a durable log or store first (acknowledge "sent"), then looks up the recipient's gateway and pushes; if the recipient is offline, the message waits in their inbox and a push notification goes out. The recipient's ack produces the "delivered" tick, opening the chat produces "read".
  • Ordering. Order only within a conversation, using a per-conversation sequence number or a time-ordered ID assigned by the conversation's shard. Global ordering is neither needed nor affordable.
  • Storage. Messages are append-heavy and read by conversation and recency, which suits a wide-column or log-structured store partitioned by conversation ID. Media goes to an object store with a CDN, and the message holds only a reference.
  • Group chats. Small groups fan out on write (copy to every member's inbox); very large groups or channels fan out on read, as in a news feed.
  • Presence and typing indicators. These are ephemeral and lossy by design: heartbeats with a TTL, throttled updates, and no durable storage. Do not push presence for every contact to every user; subscribe only to what is on screen.
  • End-to-end encryption. If asked, the server stores only ciphertext and per-device keys, which affects search, multi-device sync and backups.

How to present any case study

  1. Repeat the requirements and ask about scale. 2. Estimate traffic and storage briefly. 3. Draw the major components. 4. Zoom into the one hard problem (chunking, adaptive bitrate, spatial index, seat holds, message routing). 5. Discuss data models and consistency, then bottlenecks, failures and trade-offs. Say what you would build first and what you would postpone.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In a Dropbox-style design, why are files split into hashed chunks?

    Chunk hashes identify content. The client sends only chunks the server lacks, so small edits, retries and duplicate data are cheap.
  2. 2. How does a Netflix player avoid buffering when the network slows down?

    Adaptive bitrate streaming offers every segment at several qualities. The player measures throughput and buffer and chooses the quality of each next segment.
  3. 3. Why is a plain latitude/longitude index a poor fit for 'find nearby drivers'?

    Nearness is two-dimensional. A cell index maps a location to a cell and looks only at that cell and its neighbors.
  4. 4. Two users click the same seat at the same moment. Which design prevents a double booking?

    Only an atomic check-and-set on the seat's state guarantees one winner. The expiry returns abandoned seats to the pool.
  5. 5. In a chat system, what ordering guarantee do you normally provide?

    Users only notice order inside a chat. A per-conversation sequence assigned by the shard is cheap and correct; device clocks drift and global order does not scale.

Summary

  • A case-study answer picks the single hard problem and solves it: sync efficiency (Dropbox), adaptive delivery (Netflix), spatial lookup (Uber), contention on hot rows (BookMyShow), routing and ordering at scale (Messenger).
  • Dropbox splits files into content-hashed chunks and keeps metadata apart from content; fixed-size chunks need content-defined chunking to survive inserts.
  • Netflix encodes a bitrate ladder offline, serves immutable segments from edge caches and lets the player choose each segment's quality.
  • Uber keeps volatile driver locations in memory behind a cell index and treats trips as a durable state machine.
  • Ticket booking needs atomic seat holds with expiry, idempotent payments and a waiting room for hot releases.
  • Chat orders messages per conversation, stores messages durably before delivery and treats presence as lossy.

Next: Microservices, Kafka and Kubernetes: Resilience and Messaging Questions.