Plan HTTP Range Requests to Resume an Interrupted Video Download
Last updated: November 29, 2026
Quick Overview
The TikTok app was downloading a video file for offline viewing when the connection dropped, leaving some byte ranges received. Given the file size, the received ranges and a maximum request size, produce the HTTP Range headers needed to fetch exactly the missing bytes, and explain the networking around it.
TikTok
November 29, 20260
0
0 solved
The TikTok app was downloading a video file for offline viewing when the connection dropped, leaving some byte ranges received. Given the file size, the received ranges and a maximum request size, produce the HTTP Range headers needed to fetch exactly the missing bytes, and explain the networking around it.
TikTok's mobile clients deal with flaky cellular networks, so client engineers are expected to understand HTTP range requests, status codes and connection behavior. This phone screen mixes a small interval computation with networking questions about TCP, TLS, HTTP/2 or QUIC, and cache validation.
What the Interviewer Expects
- Merges received ranges and computes the gaps between them
- Formats inclusive byte ranges correctly (bytes=start-end)
- Splits large gaps into chunks of at most the max request size
- Explains 206 Partial Content, 200 when ranges are ignored, and 416 for bad ranges
- Mentions If-Range with an ETag so a changed file is not stitched together
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Why might QUIC (HTTP/3) recover from a network switch better than TCP?
- What happens if the CDN returns 200 with the full body instead of 206?
- Would you request many small ranges in parallel or fewer large ones, and why?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Input:
sizein bytes,received: list[(start, end_exclusive)],max_chunk. - Output: list of header values like
bytes=1000-1999covering every missing byte once. - HTTP ranges are inclusive at...
High-Level Design
Sort and merge the received ranges, then walk from 0 to size, emitting gaps. Each gap is split into pieces of at most max_chunk bytes, and each piece becomes bytes=a-b with b = end - 1.
Netwo...