qps-limit is a node.js package for providing an Express middleware that can be used to limit qps.
Installation (via npm)
$ npm install qps-limit
var express = require('express')
var qps = require('qps-limit');
var app = express()
app.use(qps({
limit: 100 // number of qps limit
}));
app.get('/user/:id', function (req, res, next) {
res.send({
code: 0,
data: {id: 1, name: 'fengliner'}
});
})
app.listen(3000, function () {
console.log('qps limit web server listening on port 3000')
})
limit
: Configures the number of qps limit. Default 1000.
The default configuration is the equivalent of:
{
"limit": 1000,
}