Worker Threads vs. Child Processes: Making the Right Choice in Node.js

Worker Threads vs. Child Processes in Node.js: When to Use Which? Early in my career when I first started working with Node.js, I loved how fast and event-driven it was. But then I hit a wall—what happens when my app needs to crunch a lot of data, like processing large files or performing complex calculations? The event loop would freeze, and everything would slow down. That’s when I discovered Worker Threads and Child Processes—two ways to run tasks in parallel without blocking the main thread....

February 24, 2025 · 5 min

Using Redis with Keyv in NestJS for Caching

Introduction Caching is essential for improving performance and reducing database load. With new update on the nestjs , there are few breaking changes modules. One of them is caching. They have migrated to Keyv In this post, I’ll show how to integrate Redis caching using Keyv in a NestJS application. Keyv is a simple key-value storage adapter that supports multiple backends, including Redis. First, install Keyv and the Redis adapter:...

February 12, 2025 · 2 min

Working with streams in NodeJS

What are Streams ? Streams are just collections of data that is sent in small chunks, and it also don’t have to fit in memory. Meaning, when dealing with big chunk of data either read or write, the memory usage is less consumed, which is extremely useful. let me show two examples how streams can be optimized the memory consumption. writeStream.js const fs = require('fs'); const file = fs.createWriteStream('file.txt'); for(let i=0; i<=2e6; i++) { file....

April 17, 2019 · 2 min