This commit is contained in:
2023-12-07 09:46:17 +01:00
parent 0a6f100685
commit 902bab14c7
2 changed files with 4 additions and 4 deletions

View File

@@ -13,9 +13,8 @@ const requestLimiter = rateLimit({
const speedLimiter = slowDown({
windowMs: 60 * 1000,
delayAfter: 30,
delayMs: 500,
skipFailedRequests: true,
delayAfter: 5,
delayMs: (hits) => hits * 100,
});
function checkSystemLoad(req, res, next) {
@@ -24,6 +23,7 @@ function checkSystemLoad(req, res, next) {
const threshold = cores * 0.7;
if (load > threshold) {
console.log('System load too high, please try again later');
return res.status(503).send(http.STATUS_CODES[503]);
}