sanjar-notes / frontend

The basics - HTML, CSS, Javascript, browser APIs, performance
3 stars 0 forks source link

Handling large files - streaming #45

Open sanjarcode opened 2 years ago

sanjarcode commented 2 years ago

Node.js streams

Situation:

  1. How does YouTube transmit chunks of video and how are they consumed by the browser.
  2. How are very large files handled by the server - during uploads/downloads.
sanjarcode commented 2 years ago

Reasons for streams:

  1. Handle large files, i.e. file size > RAM
  2. Reducing wait time - in YouTube, Spotify
sanjarcode commented 2 years ago

In other words, merely fetch/express.send is the most trivial case of downloading/uploading. These functions work only with small files.

sanjarcode commented 2 years ago

Apart from the web, streams are an important concept in computing and programming in general - reading, writing of large files, operations on a contiguous block of large size.

All programming I have done until now assumed the data I was working with was small enough to be kept fully into RAM.

sanjarcode commented 2 years ago

Simple video streaming app - HTML, Node.js

sanjarcode commented 2 years ago

https://stackoverflow.com/questions/52105758/how-is-a-browser-able-to-resume-downloads

https://en.wikipedia.org/wiki/Chunked_transfer_encoding