Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
48

Frontend System Design · Lesson 48 of 86 · 6 min

Video Streaming: HLS, DASH, Adaptive Bitrate

This is how you explain why a simple <video> tag isn't enough for a service like YouTube or Netflix.

When you're asked to design a video platform, your first instinct might be to point a <video> tag at a .mp4 file. That's called progressive download. It works for short clips, but it fails under real-world network conditions. The modern solution is adaptive bitrate streaming. After this lesson, you'll be able to explain exactly how it works, name the key protocols, and describe the frontend's role.

How Adaptive Bitrate Streaming (ABS) Works

Instead of one giant video file, ABS breaks the video into two things: small chunks of video and a playlist that describes them.

  1. Multiple Renditions: The original video is encoded into several versions at different quality levels (e.g., 360p, 720p, 1080p). Each version has a different bitrate, which is the amount of data used to represent one second of video.
  2. Segmentation: Each rendition is then chopped into small, independent segments, typically 2 to 6 seconds long. These are just static files (like .ts or .fmp4).
  3. Manifest File: A manifest file acts as a table of contents. It lists all available renditions and provides the URLs for every segment in order.
  4. Client Logic: The video player on the frontend is the smart part. It downloads the manifest first. Then it starts by requesting low-quality segments to get the video playing quickly. It continuously monitors network bandwidth and how much video is buffered. If the connection is fast, it switches to requesting higher-quality segments. If the connection slows down, it switches back down.

This all happens over standard HTTP. The segments are just files, which makes them perfectly cacheable by CDNs. This is critical for scaling video delivery globally.

The trap: Don't forget the trade-off in segment duration. Shorter segments (e.g., 2s) allow the player to adapt to network changes faster. But this also means more HTTP requests and a larger manifest file, which adds overhead. Longer segments (e.g., 10s) are more efficient but make the player less responsive to bandwidth fluctuations. Most services settle on 2-6 seconds.

HLS vs. DASH: The Two Dominant Protocols

HLS and DASH are the two standards that define the format of the manifest file and the video segments. They achieve the same goal but have different origins and syntax.

HLS (HTTP Live Streaming)

Developed by Apple. It's the de facto standard for the Apple ecosystem (iOS, Safari, Apple TV) and is widely supported everywhere else via JavaScript libraries.

  • Manifest: Uses a text-based .m3u8 playlist. It has a master playlist listing the available quality streams, and each stream has its own media playlist listing its segments.
  • Segments: Traditionally used MPEG-2 Transport Stream (.ts) containers. Modern HLS also supports Fragmented MP4 (.fmp4), which is more efficient.

DASH (Dynamic Adaptive Streaming over HTTP)

An open international standard. It's codec-agnostic and more flexible than HLS, making it popular with services like Netflix and YouTube.

  • Manifest: Uses an XML-based Media Presentation Description (.mpd) file. This format is more complex but also more powerful, allowing for more detailed descriptions of audio tracks, subtitles, and content protection.
  • Segments: Primarily uses Fragmented MP4 (.fmp4).

Here is the direct comparison you should know.

| Feature | HLS | DASH | | :--- | :--- | :--- | | Origin | Apple | ISO (Open Standard) | | Manifest | .m3u8 (text playlist) | .mpd (XML) | | Segment Format| .ts, .fmp4 (newer) | .fmp4, WebM | | Browser Support| Native on Safari/iOS. Others need hls.js. | Some native support, but dash.js is standard. |

In an interview, the correct answer to "Which one would you choose?" is almost always "Both." The media processing pipeline on the backend would generate both HLS and DASH manifests and segments to ensure compatibility across all devices. The frontend player then detects the environment and requests the appropriate manifest.

The Frontend Player's Role

A standard <video> element can't handle adaptive streaming on its own, except for Safari's native HLS support. For all other browsers, you need a JavaScript library that uses the Media Source Extensions (MSE) API.

MSE allows JavaScript to dynamically generate media streams for a <video> or <audio> element. Libraries like hls.js and dash.js use MSE under the hood. They fetch the manifest, run the adaptive bitrate logic, download the .ts or .fmp4 segments via fetch, and feed the binary data directly to the video element's buffer.

You are not implementing the ABR logic yourself. You are configuring a library that has a battle-tested implementation. Your job is to integrate it correctly.

Here is what that looks like with hls.js. This is all you'd need to show on a whiteboard.

import Hls from 'hls.js';

const video = document.getElementById('videoPlayer');
const hlsUrl = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';

if (Hls.isSupported()) {
  const hls = new Hls();
  hls.loadSource(hlsUrl);
  hls.attachMedia(video);
  hls.on(Hls.Events.MANIFEST_PARSED, () => {
    video.play();
  });
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  // Fallback to native HLS support in Safari
  video.src = hlsUrl;
}

This code checks for MSE support. If available, it uses hls.js to manage the stream. If not, it checks for native HLS support (the canPlayType check) and lets the browser handle it directly.

How to Explain Video Streaming in an Interview

Structure your answer clearly to show you understand the whole pipeline from a frontend perspective.

"For a video platform, we can't just use a standard <video src="movie.mp4">. That's progressive download, and it will buffer constantly on variable networks. The industry standard is Adaptive Bitrate Streaming.

Here's the flow:

  1. Preparation: On the backend, the source video is encoded into multiple renditions—say, 480p, 720p, and 1080p. Each rendition is then split into small, 2-6 second chunks.
  2. Manifest: A manifest file is created that acts as a playlist, listing all available quality levels and the URLs for their corresponding chunks.
  3. Protocols: The two main protocols for this are HLS and DASH. HLS uses a .m3u8 manifest and is required for Apple devices. DASH is an open standard using an XML-based .mpd manifest. A robust service provides both.
  4. Playback: On the frontend, our video player won't just point to a video file. It will use a library like hls.js or dash.js. This library first fetches the manifest. It then constantly measures network speed and buffer size to intelligently decide which quality chunk to download next, feeding them to a standard <video> element via the Media Source Extensions API. This ensures smooth playback by adapting to the user's connection."

This answer is concise, hits all the keywords (ABS, HLS, DASH, manifest, segments, MSE), and demonstrates a clear understanding of the problem and solution.

Try it

Find a public HLS stream URL (search for "public m3u8 test stream"). Paste the .m3u8 URL into your browser's address bar. Inspect the text file to see the different bitrate options (lines starting with #EXT-X-STREAM-INF) and the URL for a specific quality's playlist. Click one of those URLs to see the list of individual .ts segment files.

Next: We'll move from streaming media to fetching application data by comparing REST and GraphQL for Frontend Engineers.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Lazy Loading Images and Videos

Next

REST and GraphQL for Frontend Engineers