System Design (High-Level Design) Module 22
Case studies: links, files and media interview questions
Interview questions on “Case studies: links, files and media”: warm-ups, then what each harder question tests and how a good answer starts.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
Should a URL shortener redirect with 301 or 302?
Answered in the lesson Design a URL shortener with click analytics
-
Fresher to mid
How long should short codes be?
Answered in the lesson Design a URL shortener with click analytics
-
Fresher to mid
What is the difference between a public, an unlisted and a private paste?
A public paste can be read by anyone and may appear in the service's listings and in search. An unlisted paste can also be read by anyone, but only by someone who has its link: it is left out of every listing, so the link is the only thing that protects it. A private paste can be read only by its owner, signed in, so knowing the link is not enough. The difference shapes the design: public and unlisted pastes may be cached by a CDN, private ones never, and an unlisted paste's id must be long and random enough that nobody finds it by guessing.
From the lesson Design a paste service like Pastebin
-
Fresher to mid
Why does a music streaming service deliver audio from a CDN rather than from its own servers?
Because of the numbers. Sixty million listeners at about 100 minutes a day keep about 9 million streams playing at once at the evening peak, and at an average of about 170 kbit/s that is more than 1.5 Tbit/s. A CDN serves it from edges close to the listeners, where the popular tracks are already cached, so the service's own servers only decide what may be played and hand out signed addresses, and the origin sends just the misses. Listeners also get faster starts, because the first bytes travel a shorter distance.
From the lesson Design music streaming like Spotify
-
Fresher to mid
Why do photo apps upload originals straight to object storage instead of through their API servers?
Because the bytes would crowd out everything else the servers do. At a peak of 2,315 photos a second of 2 MB each, originals arrive at about 37 Gbit/s; an API server that relays them holds a connection and a buffer for every slow phone upload, while it should be answering small requests about posts and feeds. With a presigned address, the API server only checks that the user may upload and signs a short-lived address for one object key; the phone sends the bytes to the object store, which is built to take them, and retries go to the same key. The finished upload then raises a job for the processing pipeline.
From the lesson Design photo sharing like Instagram
-
Fresher to mid
Why is a live match delivered as short segments over HTTP rather than as one continuous stream per viewer?
Because segments can be cached and shared. The live encoder writes each few seconds of every rendition once, as a file listed in a playlist; every viewer of that rendition fetches the same files, so a CDN edge fetches each segment once and serves it to everyone nearby. A continuous stream per viewer would need a server session for each of tens of millions of viewers. Segments also let a player change bit rate at every segment boundary, recover from a dropped connection by asking for the next file, and use the same HTTP caches as everything else. The price is delay: a player starts a few segments behind the newest one.
From the lesson Design live cricket streaming like JioHotstar
-
Fresher to mid
What makes an upload resumable, and why does a video platform need it?
Answered in the lesson Design a video platform like YouTube: uploads
-
Fresher to mid
Why do video players usually start at a low rung and then switch up?
Answered in the lesson Design a video platform like YouTube: playback
-
Fresher to mid
How is a short-video feed different from a news feed built from the accounts a viewer follows?
A follower feed shows recent posts from the accounts a viewer follows, so its hard part is fan-out: copying or merging posts from many accounts. A short-video feed is mostly recommended. For each page it gathers a few hundred candidates from sources such as the viewer's interests, followed accounts, what is popular in their region and language, and new videos; a ranking model predicts how the viewer will respond to each, and rules for variety and safety set the order. It also plays one video at a time, so the next one must start the moment the viewer swipes, and the viewer's last swipes change the next page.
From the lesson Design a short-video feed like TikTok
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Mid to senior
One link on your URL shortener goes viral and draws 300,000 clicks a second for an hour, while the whole service normally peaks at 21,000. What breaks first, and how do you keep redirects fast and every click counted?
- What it tests
- Capacity arithmetic under a spike, hot keys in caches and logs, edge caching against exact counting, and degrading analytics before redirects.
- First step
- Do the capacity sum before anything else: at 4,000 redirects a second per server and 60 % utilisation, 300,000 a second needs about 125 servers, against the 11 that run today. Then follow one click and ask which component sees every request for this one code: the cache shard that owns it and the click-log partition it hashes to.
- Follow-ups
-
- The cache node that owns the code fails during the spike.
- Marketing wants the live click count on a dashboard, updated every second.
- Would you let the CDN cache this one redirect?
From the lesson Design a URL shortener with click analytics
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 4 minutes
-
Senior to staff
Your shortener must serve redirects from three regions and accept new links in all of them. How do codes stay unique without a global lock, and how does a link created in Mumbai work in Frankfurt one second later?
- What it tests
- Coordination-free code generation, global names such as aliases, replication lag and reads that must see new rows, and disabling links everywhere quickly.
- First step
- Split the question in two. Uniqueness: random codes checked only by a local key can collide across regions, but codes whose first character names the owning region cannot. Freshness: a row copied asynchronously may not have reached Frankfurt yet, so decide what a Frankfurt server does when its replica has no row for a code.
- Follow-ups
-
- Replication from Mumbai to Frankfurt falls 30 seconds behind.
- One region is cut off from the other two for an hour.
- How do you disable a link in all three regions within a few seconds?
From the lesson Design a URL shortener with click analytics
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Users report that a paste set to expire after 10 minutes could still be opened half an hour later. Where could it have come from, and how do you make expiry hold on every path?
- What it tests
- Finding every copy of a paste, the difference between reclaiming space and controlling access, cache lifetimes tied to expiry, and testing time-based behaviour.
- First step
- List every place a reader can get the text from: the browser's cache, the CDN's edges, the service's own cache, the metadata row and the object store. For each, ask what decides when it stops serving the paste, and whether that rule knows about the 10 minutes.
- Follow-ups
-
- The CDN keeps some responses longer than your max-age says.
- Expired pastes still count against their owners' storage quotas.
- How would you test that expiry holds before every release?
From the lesson Design a paste service like Pastebin
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Unlisted pastes are protected only by their link. How long must their ids be, and what else keeps people from finding unlisted pastes they were never sent?
- What it tests
- Turning a guessing rate into an id length, secure random generation, and the other ways links leak: listings, search engines, referrers and logs.
- First step
- Write down the attacker's numbers before choosing a length: how many unlisted pastes exist, how many guesses a second a determined attacker can make, and how many pastes found a day you would accept. The chance that one guess hits is the live count divided by the number of possible ids.
- Follow-ups
-
- Your ids are 8 characters today and 300 million pastes exist. What do you do about them?
- A search engine has indexed some unlisted pastes.
- Would UUIDs be good enough as ids?
From the lesson Design a paste service like Pastebin
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A government order to remove a public paste arrives at 2 a.m., and the law gives your service only a few hours. Design the path from the order to the paste being gone everywhere, and say what you keep afterwards.
- What it tests
- Treating a legal deadline as a requirement, removal across caches and copies, evidence preservation, and proving later what was done and when.
- First step
- Work backwards from the deadline. Someone must see the order, check that it is genuine and that it names a paste you host, remove it from the origin and from every CDN edge, and confirm that it is gone, all inside the window, at night. Then ask which of those steps a tool can do in one action.
- Follow-ups
-
- The same text has been pasted twenty more times since.
- The order turns out to be forged.
- How do you prove months later that you met the deadline?
From the lesson Design a paste service like Pastebin
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A track's licence in one country ends at midnight local time, while it stays licensed everywhere else. How do you stop playback there on time, including on phones that downloaded the track?
- What it tests
- Time windows as UTC instants, checks at playback time, cache expiry at window edges, offline licences bounded by the window, and untrusted device clocks.
- First step
- Turn "midnight local time" into one exact instant, then find every place that could still let the track play after it: cached availability answers, playlists and pages, signed audio addresses already handed out, and downloads on phones that may stay offline.
- Follow-ups
-
- A listener sets the phone's clock back by a day.
- The licence end is moved two weeks earlier, at short notice.
- Someone is halfway through the track at midnight.
From the lesson Design music streaming like Spotify
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Royalties are paid on play counts. Design play counting so that retried uploads, a phone that was offline for two weeks and an account that loops one song all day do not distort what rights holders are paid.
- What it tests
- Idempotent event ids, dating plays by when they happened, late data and closing periods, artificial plays, and reconciliation that explains every difference.
- First step
- Define a play before counting anything: which device makes the event, which id it carries, which clock dates it, and how long it must last. Then follow the three cases through the pipeline and see where each would be counted twice, late or wrongly.
- Follow-ups
-
- The live dashboard and the royalty report disagree for one track.
- A label says its plays in one market were undercounted last month.
- How long do you keep raw play events?
From the lesson Design music streaming like Spotify
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A famous artist's album opens at midnight local time in every market, and 20 million people press play within ten minutes of their market's opening. What breaks first, and how do you prepare?
- What it tests
- Cold caches at a known instant, availability that flips on time, load arriving in waves, client retries, and protecting the counting path.
- First step
- Separate what is new at that instant from what is merely busy. The audio files and the availability answers for the new tracks are cold or about to change, while playback tokens and play events are ordinary traffic at a higher rate. Then put numbers on each for the biggest market's ten minutes.
- Follow-ups
-
- In one market the album still shows as unavailable ten minutes after midnight.
- Clients retry a failed start every second.
- The album must not leak before the release, even though the files are already at the edges.
From the lesson Design music streaming like Spotify
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A user says a photo they posted revealed their home address. How could that happen in your design, and how do you make sure it never happens again, including for photos already published?
- What it tests
- Knowing where location data lives in an image, stripping it by allowlist and re-encoding, every path that could serve an original, and repairing what is already published.
- First step
- List every way a viewer could receive bytes of that photo: each rendition, the original, a cached copy at the CDN, a download or share link, and any service that copies images onward. Then ask which of them could still carry the Exif GPS tags that the phone wrote.
- Follow-ups
-
- How do you find every published image that still carries a location?
- A photographer wants the camera details kept for their followers.
- Could the place be recovered from the picture itself?
From the lesson Design photo sharing like Instagram
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
An account with 300 million followers posts a photo. Walk through what your feed, your like counts and your image delivery do in the first five minutes.
- What it tests
- Hybrid fan-out with a threshold, a cached list of a large account's recent posts, sharded counters, and a cold image becoming the hottest object in every CDN.
- First step
- Put numbers on each path. Pushing the post into 300 million inboxes takes five minutes at a million writes a second; if 10 % of followers open the app within those minutes, 30 million feed reads must include it; and the same image is requested by all of them from caches that have never seen it.
- Follow-ups
-
- The account deletes the post after two minutes.
- The likes arrive at 80,000 a second for ten minutes.
- Followers in one region all request the image at the same second.
From the lesson Design photo sharing like Instagram
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
Image storage has become the largest line on the bill, and most photos older than a month are rarely viewed. How do you cut the cost without slowing down the photos people still open?
- What it tests
- Effective replication factors, erasure coding and warm tiers, choosing what to keep per photo, small-object overhead, and measuring temperature by age and requests.
- First step
- Split the bill into its factors: photos kept, bytes kept per photo across originals and renditions, and the raw copies kept per byte. At 117 PB of new photos a year, each factor is worth measuring before choosing what to change.
- Follow-ups
-
- A month-old photo suddenly goes viral again.
- Would you delete the originals once the renditions exist?
- How would you prove that the change made nothing slower?
From the lesson Design photo sharing like Instagram
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
Viewers double from 40 to 80 million during the last overs of a close chase. What breaks first in your design, and what did you prepare before the match so that nothing does?
- What it tests
- Capacity reserved across CDNs, the cost of new starts against existing viewers, sizing the playback service, degradation in a fixed order and warm caches.
- First step
- Separate the viewers already watching from the ones arriving. Existing viewers cost egress and edge requests; each arriving viewer also costs a playback call, a token, a playlist and a burst of segments to fill its buffer. Put numbers on both for the steepest minute before deciding what to scale.
- Follow-ups
-
- One CDN reports that its busiest region is full.
- The playback service's database slows down at the peak.
- What do you switch off first, and what never?
From the lesson Design live cricket streaming like JioHotstar
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Ten minutes into a match, requests at the origin jump from about 60 a second to millions, while the number of viewers stays flat. What do you check first, and how do you stop it?
- What it tests
- Cache keys and request collapsing, shields, configuration changes as the cause of incidents, and protecting the origin while the cause is fixed.
- First step
- Start from what did not change: the viewers. If they are flat, the edges and shields must be passing on more requests per segment than before, so take several origin requests for the same segment and compare them field by field before touching any capacity.
- Follow-ups
-
- The cause is a CDN configuration change pushed that morning.
- The origin must stay up while you roll it back.
- How do you catch this before the next match?
From the lesson Design live cricket streaming like JioHotstar
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
Every viewer reaches an ad break within the same 15 seconds. Design ad insertion so that 80 million viewers see ads without overloading the ad decision service or delaying the match.
- What it tests
- Server-side ad insertion, deciding ahead of the break, cohorts against personal targeting, caching stitched playlists and ad segments, and fallbacks.
- First step
- Do the naive arithmetic first: 80 million decisions inside 15 seconds is 5.3 million a second. Then ask how early a decision could be made, and how many viewers one decision could serve.
- Follow-ups
-
- An advertiser wants a different ad for every viewer.
- The decision service is down for one break.
- How do you count the ads that were actually watched?
From the lesson Design live cricket streaming like JioHotstar
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
A creator uploads a two-hour 4K film and expects it to be watchable within 10 minutes of the upload finishing. How do you plan its processing, and what limits how fast it can go?
- What it tests
- Parallel work through chunks at key frames, the critical path of a job graph, low rungs first, and the costs and limits that parallel work adds.
- First step
- Write the work out as a graph: probe, split, one transcode per chunk and rung, packaging per rung, the checks and the captions. Add up the worker-seconds, then ask which single tasks no number of workers can shorten, because those set the time.
- Follow-ups
-
- The copyright check alone takes eight minutes.
- 500 other uploads are already waiting in the queue.
- The workflow engine refuses to schedule more activities.
From the lesson Design a video platform like YouTube: uploads
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
Encoding costs have doubled in a year, yet most uploads are watched only a few times. How would you cut the cost of transcoding without viewers noticing?
- What it tests
- Turning the ladder into a cost model, encoding by demand, what viewers lose while a rung is missing, and the risk of encoding at the moment of demand.
- First step
- Split the cost by rung: worker-seconds per second of video for each rung, times the hours uploaded. Then set it against how views are spread over uploads, and ask which rungs most videos ever need.
- Follow-ups
-
- A video with only its low rungs suddenly goes viral.
- How do you decide when a video has earned its high rungs?
- Would a newer, more efficient codec help or hurt?
From the lesson Design a video platform like YouTube: uploads
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Senior to staff
A video was published an hour ago, and now the copyright check reports a match that requires blocking it in two countries. Walk through what the system does, and how you make sure it is really gone there.
- What it tests
- Verdicts that arrive after publication, visibility per country, the copies that caches and signed addresses keep, telling the creator, and proving when the block took effect.
- First step
- List everywhere the video can still be served from in those two countries: CDN edges, cached playlists and segments, playback addresses already handed out, search and recommendations. Then decide which record changes and how each copy learns about it.
- Follow-ups
-
- The creator disputes the claim.
- A viewer in one of the countries is halfway through the video.
- The same reference later matches 10,000 other videos.
From the lesson Design a video platform like YouTube: uploads
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
Most of your billion videos are watched only a few times a month, and viewers complain that those start slowly while popular videos start at once. Find the cause and fix it without caching everything everywhere.
- What it tests
- Edge misses on the long tail, the cost of each request that goes to the origin, the unit of caching, cache tiers, and measuring start-up time in the field.
- First step
- Trace one start of a rarely watched video: the API call, the playlists, the first segment, and which of them miss at the edge. Then count the requests that go all the way to the origin and what each one costs.
- Follow-ups
-
- How much cache would the first minute of every video take?
- Should the edge fetch the next segments before the player asks?
- How do you measure start-up time from the field?
From the lesson Design a video platform like YouTube: playback
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
A video draws 50,000 views a second during a launch. Its count must update within a minute, must not count replays or bots, and creators are paid from it. Design the counting.
- What it tests
- Write contention on one row, removing repeats per viewer, automated traffic, flushing sums from a stream exactly once, and separating the count shown from the count paid on.
- First step
- Write down what one view is (per viewer, per video, in what window) and who reads the count: the page, the creator, payments. Then work out what 50,000 increments a second do to one row.
- Follow-ups
-
- A stream partition crashes after writing its sums.
- A bot farm replays the video from thousands of accounts.
- The creator's dashboard and the public count disagree.
From the lesson Design a video platform like YouTube: playback
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
A viewer watches a film on the phone during a commute, then opens it on the television at home. Design saving and resuming the position for 300 million viewers, including a phone that was offline for the last ten minutes.
- What it tests
- The write rate of position saves, the store and its key, conflicts between devices, saves that arrive late, and what a viewer loses when an app is killed.
- First step
- Estimate the saves first: streams at the peak divided by how often each one saves. Then choose the key, and what decides which of two saves for the same video wins.
- Follow-ups
-
- The phone's saves arrive after the television has moved on.
- A viewer removes a video from the watch history.
- How long do you keep positions of finished videos?
From the lesson Design a video platform like YouTube: playback
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
Viewers on mobile networks say the next video often takes a moment to start after a swipe, and your data costs keep rising. How do you make swipes instant without wasting data?
- What it tests
- What must be on the phone before a start, how many videos to fetch ahead, how far ahead to fetch the video on screen, the rung of prefetched segments, and measuring delay and waste together.
- First step
- Write down what has to be on the phone for the next video to start, and how large it is at each rung. Then list where the downloaded bytes go: the video on screen, the next videos, and what is thrown away on a swipe.
- Follow-ups
-
- The viewer is on a capped data plan.
- The network drops to 0.3 Mbit/s in a tunnel.
- How would you know the change worked?
From the lesson Design a short-video feed like TikTok
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
A creator with no followers uploads a video. How does it reach its first viewers, how does the system decide whether to show it to more people, and how do you keep a harmful video from spreading meanwhile?
- What it tests
- Exploration as a budget of impressions, choosing first audiences, comparing early engagement fairly, and moderation gates tied to each step of reach.
- First step
- Put a number on exploration first: uploads a day times the size of a first audience, against all the videos started in a day. Then decide what a video must show before it earns a larger audience, and what must be checked before each step.
- Follow-ups
-
- A video turns out to be harmful only after 10,000 views.
- New creators complain that nobody sees their videos.
- The first audience of a video in a small language is tiny.
From the lesson Design a short-video feed like TikTok
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
Your ranker uses views in the last 10 minutes to spot rising videos. After a 3-minute intake outage it demoted every new video, then promoted them all at once. Explain what happened and redesign the feature pipeline.
- What it tests
- Processing time against event time, watermarks and allowed lateness, backlog replays, late updates, and how a ranker should read features that are still changing.
- First step
- Ask which clock the windows use, and follow the 3 minutes of views from the phones to the windows: when did each of them arrive, and which window counted it?
- Follow-ups
-
- How late may an event be and still count?
- The ranker cached the wrong value for 10 minutes.
- How do you test the pipeline before the next outage?
From the lesson Design a short-video feed like TikTok
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
All System Design (High-Level Design) interview questions · The System Design (High-Level Design) track