Node.js FAQ: Top Questions
36. What is rate limiting in Express.js?
Rate limiting in Express.js restricts the number of requests a client can make within a time window, preventing abuse and ensuring fair resource usage.
-
Middleware:
express-rate-limit
is commonly used. - Configuration: Set max requests, time window, and storage (e.g., memory, Redis).
- Benefits: Protects against DoS attacks, API overuse.
- Use Case: Public APIs, authentication endpoints.