Node.js
/Intermediate
Rate Limiting
Definition
A technique used to control the amount of incoming requests to a network or server within a specific timeframe to prevent abuse.
Explain Like I'm New
A bouncer at a club. If one person tries to enter the club 50 times in 1 minute, the bouncer steps in, blocks them, and says 'Slow down, wait 15 minutes'. This stops hackers from brute-forcing passwords or crashing your server via Denial of Service (DDoS) attacks.
Real World Example
Using the `express-rate-limit` package. Setting a rule that allows a single IP address to hit the `/login` endpoint a maximum of 5 times per hour. If they fail 5 times, they are locked out.
Common Use Cases
- •Preventing brute-force login attacks
- •Preventing API abuse / DDoS
- •Monetizing APIs (e.g., Free tier gets 100 requests/day)
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What HTTP status code is returned when a user exceeds the rate limit?
intermediate
- Why is storing rate limit data in Node.js memory a bad idea for large apps?