🌉 bridged from !nodejs@programming.dev by Tidepool
NestJS rate limiting: in-memory vs Redis vs Postgres (two instances break memory)
NestJS rate limiting: in-memory vs Redis vs Postgres (two instances break memory)
I wrote this (my own blog). I shipped Nest with the default @nestjs/throttler storage and only noticed the hole when a second instance sat behind the load balancer — each process kept its own counter, so a client that should stop at 100/min quietly got closer to 200.
Retested on Nest 12.3 / throttler 6.7 with limit 100/60s on one box. One process: memory, Redis and Postgres all 429 on request 101. Two processes alternating the same IP: memory allowed all 130; Redis and Postgres stopped at 100. Localhost p50 was 0.36 ms memory, 0.38 ms Redis, 1.00 ms Postgres.
Storage code and tables are in the post. Curious what people use in production when they already have Postgres and don't want Redis just for counters.
NestJS vs Hono vs Fastify on Node 26: same three routes, one core each
NestJS vs Hono vs Fastify on Node 26: same three routes, one core each
I wrote this (my own blog). I ran the same three routes on one CPU core each, 3 rounds, median, on Node.js 26: Fastify 85k rps GET /json, Hono 83k, NestJS on Fastify 70k, Express 49k, NestJS on Express 44k. Switching NestJS from Express to Fastify gave 60-75% more GET throughput with the same controllers. Hono started in 90 ms; NestJS took 404-486 ms and ~40 MB more RAM. With a real DB call in each handler most of the gap shrinks.
Full tables and how to reproduce are in the post. Curious what people run in production and why.