Challenge - 5 Problems
Rate Limit Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:00remaining
What is the HTTP status code returned for a rate limit error?
When a REST API enforces rate limiting and a client exceeds the allowed number of requests, what HTTP status code should the server return?
Attempts:
2 left
💡 Hint
Think about the standard HTTP status code specifically designed for rate limiting.
✗ Incorrect
The HTTP status code 429 Too Many Requests is the standard response when a client has sent too many requests in a given amount of time.
❓ Predict Output
intermediate1:00remaining
What header informs the client about when to retry after rate limiting?
Which HTTP response header tells the client how many seconds to wait before making another request after hitting a rate limit?
Attempts:
2 left
💡 Hint
This header is part of the HTTP standard and indicates wait time.
✗ Incorrect
The Retry-After header tells the client how many seconds to wait before retrying the request.
🧠 Conceptual
advanced1:30remaining
Why is it important to include rate limit headers in error responses?
Why should a REST API include headers like
Retry-After or X-RateLimit-Remaining in responses when rate limiting is applied?Attempts:
2 left
💡 Hint
Think about how clients can behave better with more information.
✗ Incorrect
Including rate limit headers helps clients know when to retry and how many requests remain, improving user experience and reducing server overload.
❓ Predict Output
advanced1:30remaining
What is the typical JSON body content of a rate limit error response?
Given a REST API returns a 429 status code, which JSON response body best informs the client about the rate limit error?
Attempts:
2 left
💡 Hint
Look for a message about rate limiting and a retry time.
✗ Incorrect
The JSON body should clearly state the error and provide a retry time in seconds to guide the client.
🔧 Debug
expert2:00remaining
Identify the error in this rate limit middleware code snippet
This code snippet is intended to return a 429 error with a Retry-After header when the client exceeds the rate limit. What is the error?
Rest API
function rateLimit(req, res, next) {
if (req.requests > 100) {
res.status(429);
res.set('Retry-After', '60');
res.send({ error: 'Rate limit exceeded', retry_after: 60 });
return;
}
next();
}Attempts:
2 left
💡 Hint
Think about what happens after res.send() is called in middleware.
✗ Incorrect
Calling next() after sending a response causes the next middleware to run and may try to send another response, leading to errors.