Challenge - 5 Problems
429 Too Many Requests Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the HTTP status code returned?
You have a REST API that limits clients to 5 requests per minute. If a client sends 6 requests quickly, what HTTP status code will the server return for the 6th request?
Attempts:
2 left
💡 Hint
Think about what status code means the client sent too many requests in a short time.
✗ Incorrect
The 429 status code means the client has sent too many requests in a given amount of time, triggering rate limiting.
🧠 Conceptual
intermediate1:00remaining
Why use 429 Too Many Requests status code?
Which reason best explains why an API uses the 429 Too Many Requests status code?
Attempts:
2 left
💡 Hint
Think about what happens when a client sends too many requests too fast.
✗ Incorrect
429 status code tells the client to slow down because it has sent too many requests in a short time.
🔧 Debug
advanced2:00remaining
Identify the cause of unexpected 429 errors
A client reports receiving 429 Too Many Requests errors even though they send only 1 request per minute. What is the most likely cause?
Attempts:
2 left
💡 Hint
Consider server settings that control request limits.
✗ Incorrect
If the server's rate limit is too low or misconfigured, it may block even low-frequency requests with 429 errors.
🚀 Application
advanced1:30remaining
How to handle 429 errors in client code?
You receive a 429 Too Many Requests response from an API. What is the best way for your client application to handle this?
Attempts:
2 left
💡 Hint
Look for a header that tells you when to try again.
✗ Incorrect
The Retry-After header tells the client how long to wait before retrying after a 429 response.
❓ Predict Output
expert3:00remaining
What is the output of this rate limiting code snippet?
Consider this Python Flask snippet implementing simple rate limiting. What will be the output on the 4th request from the same IP within 10 seconds?
Rest API
from flask import Flask, request, jsonify import time app = Flask(__name__) request_times = {} @app.route('/api') def api(): ip = request.remote_addr now = time.time() times = request_times.get(ip, []) # Remove timestamps older than 10 seconds times = [t for t in times if now - t < 10] if len(times) >= 3: return jsonify({'error': 'Too many requests'}), 429 times.append(now) request_times[ip] = times return jsonify({'message': 'Success'}) # Simulate 4 requests from same IP quickly ip = '192.168.1.1' for i in range(4): request_times[ip] = [time.time() - 1, time.time() - 2, time.time() - 3] now = time.time() times = request_times.get(ip, []) times = [t for t in times if now - t < 10] if len(times) >= 3: print(429) else: times.append(now) request_times[ip] = times print(200)
Attempts:
2 left
💡 Hint
Check how many timestamps are kept and when 429 is returned.
✗ Incorrect
The code allows 3 requests within 10 seconds. The 4th request triggers 429.