When to use Redis

Share rate limits across multiple Node instances (production).

When to use Redis

On production you usually run Node on multiple instances: several containers, a PM2 cluster, or more than one server. Each process has its own memory. The in-memory RateLimiter only knows about one process, so “max 100 per minute” would mean 100 per minute per instance — e.g. 5 instances = 500 per minute. To enforce one shared limit across all of them, use DistributedRateLimiter with Redis.

Example: you want “at most 100 API calls per minute” across 5 instances. With Redis, all 5 share the same counter. With in-memory only, each instance could do 100 per minute on its own.

Quick comparison

RateLimiterDistributedRateLimiter
StateIn one processIn Redis (shared)
Use whenSingle process (dev, or one instance)Production: multiple instances, one shared limit
DependencyNoneRedis (ioredis)

Next: Setup & connection.