We want to have a http server that lives under high load and stay responsive, especially for health checks and metrics.
For this purpose, we use a custom requests limits. Main principles is to check current event loop lag metric, split requests processing to different event loop tasks and to limit the number of concurrent requests.
Main reference for this limiter is awesome under-pressure library.
This repo contains a simplified version of limiter.
In Node.js version 16, 18 and 19, custom requests limits works - the server is responsive for new requests and health checks responds fast.
In Node.js version 20 and 22, health checks processing is very slow.
-
Install dependencies
npm install
-
Run http server with Node.js 18
nvm use 18 npm start
-
Run tests, expected to fast
/readyz
responses (<500ms)npm test
-
Run http server with Node.js 22
nvm use 22 npm start
-
Run tests, expected to slow
/readyz
responses (>10s)npm test