0
0
Nginxdevops~20 mins

limit_req_zone and limit_req in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rate Limiting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this limit_req_zone directive?
Given the configuration snippet:
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=5r/s;

What does this directive do in NGINX?
Nginx
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=5r/s;
AIt allows unlimited requests but logs client IPs in a 10MB zone named 'mylimit'.
BIt limits total server requests to 5 per second, using 10MB memory for buffering.
CIt blocks any client IP that sends more than 5 requests in total, using 10MB disk space.
DIt limits requests to 5 requests per second per unique client IP, storing state in a 10MB shared memory zone named 'mylimit'.
Attempts:
2 left
💡 Hint
Think about what $binary_remote_addr and rate=5r/s mean in this context.
💻 Command Output
intermediate
2:00remaining
What happens when this limit_req is applied?
Given this snippet inside a server block:
limit_req zone=mylimit burst=10 nodelay;

What is the behavior of NGINX when requests exceed the rate defined in the zone?
Nginx
limit_req zone=mylimit burst=10 nodelay;
ANGINX queues requests indefinitely until the rate drops below the limit.
BNGINX allows up to 10 extra requests to queue immediately without delay, then rejects further requests with 503 error.
CNGINX rejects any request exceeding the rate immediately without queuing.
DNGINX delays all requests by 10 seconds before processing them.
Attempts:
2 left
💡 Hint
Consider what 'burst' and 'nodelay' mean for request handling.
Troubleshoot
advanced
2:00remaining
Why does this NGINX config cause a syntax error?
Identify the cause of the syntax error in this configuration:
limit_req_zone $remote_addr zone=one:10m rate=1r/s
limit_req zone=one burst=5;
Nginx
limit_req_zone $remote_addr zone=one:10m rate=1r/s;
limit_req zone=one burst=5;
AMissing semicolon at the end of the first line causes syntax error.
BUsing $remote_addr instead of $binary_remote_addr is invalid in limit_req_zone.
CThe zone name 'one' is too short and invalid.
DThe burst parameter cannot be used without nodelay.
Attempts:
2 left
💡 Hint
Check punctuation at the end of each directive line.
Best Practice
advanced
2:00remaining
Which is the best way to avoid blocking legitimate users with limit_req?
You want to limit request rates but avoid blocking users who occasionally send bursts of requests. Which configuration is best?
AUse limit_req with a burst value and no nodelay to allow queued requests to be delayed.
BUse limit_req_zone with a very low rate and no burst to strictly block excess.
CUse limit_req with burst=0 to reject all excess requests immediately.
DDisable limit_req and rely on firewall rules instead.
Attempts:
2 left
💡 Hint
Think about how burst and nodelay affect request queuing and delays.
🔀 Workflow
expert
3:00remaining
Order the steps to configure rate limiting with limit_req_zone and limit_req
Put these steps in the correct order to implement rate limiting in NGINX using limit_req_zone and limit_req.
A1,3,2,4
B2,1,3,4
C1,2,3,4
D2,3,1,4
Attempts:
2 left
💡 Hint
Think about defining the zone before using it, then applying and testing.