Hardest Backend Node.js Concept to Master

Hardest Backend Node.js Concept to Master

Streams is a very important topic when working with applications with large data or when performance is your main concern.

Let’s say you have a computer with a 2TB game file and the server has an 8GB ram with a 4TB SSD and you want to upload the file to the server with a simple webpage. You can upload the game file to the server but it has only 8GB ram, so it’s not possible to do it all at once, so the client starts streaming the data to the server just like how videos work on Youtube. This works both ways so the server can send the data to the user as well.

In Node.js there are four types of streams namely:

  1. Readable
  2. Writable
  3. Duplex
  4. Transform

In Duplex streams, we can Read and Write the data whereas in Read, we can only Read the data and in Write, we can only write the data. A Transformation Stream is where you pass the data through a filter that changes how the data behaves once it comes out of it.

Read and Write can be piped together to be used on Sockets. Web Sockets at a low level are also kind of like Read and Write Streams. TCP Sockets actually opens in a Duplex stream because you as the client can Read and Write on it as well as the server can Read and Write on it

Sharing is caring

Did you like what Agam singh, Aman Ahmed Siddiqui, Aman Chopra, Aman, Amol Shelke, Anas Khan, Anirudh Panda, Ankur Balwada, Anshul Soni, Arif Shaikh, wrote? Thank them for their work by sharing it on social media.


No comments so far