Questions
3 of 24
1What are streams?
2List elementary stream types.
3What are advantages of streams.
4Create a readable stream
5How can you create a custom Transform stream in Node.js?
6What is the `end` event in a readable stream, and how is it different from the `finish` event in a writable stream?
7How can you handle errors in Node.js streams?
8Explain the concept of object streams and provide an example use case.
9Explain the difference between `ObjectMode` and `Buffer` mode in a readable stream.
10Explain the difference between a flowing and a non-flowing readable stream.
11What is the difference between the `data` event and the `readable` event in a readable stream?
12How can you handle cleanup operations when working with streams?
13What is the purpose of the `highWaterMark` option when creating a readable stream?
14What is backpressure in Node.js streams, and how can you handle it?
15What is the pause() method used for in a readable stream, and how can you resume data flow?
16What is the purpose of the `stream.finished()` utility in Node.js?
17How do you handle stream errors when working with async/await in Node.js?
18How can you handle memory usage when dealing with large files in Node.js streams?
19Explain the concept of piping in Node.js streams.
20What is the purpose of pipeThrough function
21What is the purpose of the `unpipe()` method in Node.js streams, and how does it work?
22Explain the difference between `pipe()` and `on('data')` when working with streams.
23What is the purpose of the `stream.pipeline()` function in Node.js?
24write code of a stream to read a local file in node js
03 / 24

What are advantages of streams.

Difficulty: 5/10
memory efficiency, backpressure, composability

What makes streams unique, is that instead of a program reading a file into memory all at once like in the traditional way, streams read chunks of data piece by piece, processing its content without keeping it all in memory.

Streams provide two major advantages compared to other data handling methods:
  1. 1

    Memory efficiency: We don’t need to load large amounts of data in memory before we are able to process it

  2. 2

    Time efficiency: We can start processing data as soon as we have it, rather than having to wait with processing until the entire payload has been transmitted

Scenario Questions

0-2 years experience

  1. 1You need to read a 200 MB CSV file and process each line without loading the whole file into memory. How would you use Node.js streams to implement this?
  2. 2If you pipe a readable stream into a writable stream and the writable stream encounters an error, what happens to the readable stream and how should you handle it?
  3. 3What is the practical difference between using `fs.readFile` and creating a read stream for a large file, in terms of memory usage and latency?

2-5 years experience

  1. 1Your service streams video data from disk to an HTTP response, but under load you notice occasional buffering and high memory usage. Walk me through how you would diagnose and fix the issue using stream features.
  2. 2You added a Transform stream to compress data before sending it to an external API, but the downstream API sometimes returns 429 errors. How would you adjust your stream pipeline to respect backpressure?
  3. 3Explain why mixing async functions with streams can cause the pipeline to break, and how you would refactor it for reliable flow control.

5-8 years experience

  1. 1Design a data ingestion pipeline that reads from a Kafka topic, transforms records, and writes to S3, all using Node.js streams. Discuss how you would handle backpressure, fault tolerance, and scaling.
  2. 2Your microservice processes uploaded files using streams, but a bug causes the process to hang when a client aborts the upload. How would you redesign the stream handling to ensure resources are released promptly?
  3. 3Compare using Node.js streams versus a message queue for passing large payloads between services. What trade‑offs influence your choice at scale?

8+ years experience

  1. 1Our platform is migrating legacy file‑processing jobs that use `fs.readFile` into a streaming architecture. What architectural considerations, testing strategies, and migration steps would you propose to minimize risk?
  2. 2Across multiple teams, some services use native streams while others rely on third‑party libraries that wrap streams. How would you establish a unified streaming strategy and enforce consistency while allowing flexibility?
  3. 3Looking ahead, how would you evolve a streaming‑based data pipeline to support schema evolution and real‑time analytics without disrupting existing consumers?

Follow-up Questions

  • How do you detect and react to backpressure in a custom Transform stream?
  • What metrics would you monitor in production to ensure a streaming pipeline stays healthy?
  • Can you walk me through how errors travel through a pipe chain and how you would catch them?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.