R
R
retyui2015-04-15 02:55:36
Node.js
retyui, 2015-04-15 02:55:36

Restrictions on the number of requests per second?

A sample solution for a nodejs + expressjs problem or idea !

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur Shemsedinov, 2015-04-15
@retyui

The question is unclear. You have a problem that express gives little RPS (requests per second) and you want to find a solution how to increase RPS or vice versa, you want to limit the number of RPS for the system as a whole or for each IP or for each URL or for each session ?
If the first, then you need to scale using cluster, combine several machines into a cluster using load balancers (software like nginx or hardware), you need to move the statics to the CDN, leaving only the API on the server (only dynamic requests), and optimize your own code. If all this does not give the desired result and you have to have too many servers and additional services, they all cost money and need constant support, administration, configuration, updating, monitoring ... and you cannot pay off with such a model or want to to drastically reduce hosting costs, then you need to abandon express at the very beginning of development, and write either on a clean node or on a more productive framework.
If the second, then this may be the task of a router or a load balancer, if it is necessary to introduce restrictions on the parameters that can be obtained from the HTTP packet directly (IP, cookies, URL). This can also be the task of the application, if the RPS restrictions concern some objects, requests to which cannot be limited through the parameters received by routers from HTTP packets. But this is very rare when the application should limit RPS itself, it is advisable to avoid this by reworking the URL and adding cookies, for example.

R
Roman, 2018-06-12
@Animir

Better at the level of web server, load balancer, CDN, etc. do it.
But if it is not possible for some reason, then https://github.com/animir/node-rate-limiter-flexible will help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question