API with NestJS #24. Cache With Redis. Running The App in A Node.js Cluster - We look into using Redis as a cache and run multiple instances of our application with a Node.js cluster.
Redis is a fast and reliable key-value store. It keeps the data in its memory, although Redis, by default, writes the data to the file system at least every 2 seconds.
In the previous part of this series, we’ve used a cache stored in our application’s memory. While it is simple and efficient, it has its downsides. With applications where performance and availability are crucial, we often run multiple instances of our API. With that, the incoming traffic is load-balanced and redirected to multiple instances.
Unfortunately, keeping the cache within the memory of the application means that multiple instances of our API do not share the same cache. Also, restarting the API means losing the cache. Because of all of that, it is worth looking into Redis.
Building Modern Nodejs Application using Nestjs and TypeScript - In this article, we will see how to build REST API using Nestjs with TypeScript. Building Modern Nodejs Application using Nestjs and TypeScript