QA
Beginner LevelSystem Design & Architecture

What is Rate Limiting and how does it protect backend servers from traffic surges?

❓ Interview Prompt: Explain Rate Limiting, HTTP 429 Too Many Requests, protecting against DoS attacks, Token Bucket algorithm, and client throttling.

Rate Limiting caps the maximum number of requests a client IP or authenticated user can submit within a specified time window:

Why Rate Limiting is Mandatory:

β€’
Prevents Denial of Service (DoS) attacks and web scraping.
β€’
Protects downstream databases from being overwhelmed during traffic spikes.
β€’
Returns standard '429 Too Many Requests' HTTP status code with 'Retry-After' response headers.

Code Implementation Example

typescript
// Rate limiting header response format
res.setHeader('X-RateLimit-Limit', '100');
res.setHeader('X-RateLimit-Remaining', '0');
res.setHeader('Retry-After', '60');
res.status(429).json({ error: 'Rate limit exceeded. Try again in 60 seconds.' });
πŸ’‘Returning HTTP 429 Rate Limit Exceeded headers.
🎯 Interview Key Takeaway

Enforce rate limiting on all public API endpoints to protect backend infrastructure from DoS and traffic spikes.

#System Design#Rate Limiting#Throttling#HTTP 429#Beginner
Back to all System Design & Architecture Questions→

More System Design & Architecture Interview Questions

Beginner LevelSystem Design & Architecture

Explain the CAP Theorem and PACELC Theorem with real-world database examples.

Beginner LevelSystem Design & Architecture

What is Vertical Scaling (Scale Up) vs Horizontal Scaling (Scale Out)?

Beginner LevelSystem Design & Architecture

How do Load Balancers distribute traffic (Round Robin, Least Connections, IP Hash)?