A Koa middleware function that checks system pressure and responds accordingly.
When the system is detected to be under pressure, the middleware:
Retry-After
header.app.use(underPressureKoaMiddleware({
sampleIntervalInMs: 1000,
resolution: 10,
webServerMetricsPort: 9090,
maxEventLoopDelay: 1000,
maxEventLoopUtilization: 0.9
}));
Creates a Koa middleware that monitors system metrics and responds with a 503 Service Unavailable status when the system is under pressure, as determined by the provided options and current metrics.