Bird
Raised Fist0
Nginxdevops~10 mins

Burst and nodelay options in Nginx - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Burst and nodelay options
Request arrives
↓
Check token bucket
↓
Tokens available?
No→Queue request if burst > 0
↓
Queue full?
↓
Allow request
↓
Process request
↓
Next request
Requests check tokens; if none, burst allows queuing; nodelay controls immediate processing of queued requests.
Execution Sample
Nginx
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;
limit_req zone=mylimit burst=3 nodelay;

# Requests come in quickly
Limits requests to 1 per second, allows 3 extra bursts, and nodelay sends bursts immediately without delay.
Process Table
StepIncoming Request #Tokens AvailableBurst Queuenodelay EffectAction Taken
1110nodelay onRequest allowed immediately, tokens now 0
2200nodelay onBurst queue used (1), request allowed immediately
3301nodelay onBurst queue used (2), request allowed immediately
4402nodelay onBurst queue used (3), request allowed immediately
5503nodelay onBurst full, request delayed or rejected
661 (refilled)3nodelay onToken refilled, request allowed immediately
7703nodelay onNo tokens, burst full, request delayed or rejected
💡 Requests stop being allowed immediately when burst queue is full and no tokens are available.
Status Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7
Tokens Available10000010
Burst Queue00123333
Key Moments - 3 Insights
Why does the burst queue fill up even when tokens are zero?
Because burst allows extra requests beyond tokens to queue temporarily, as shown in steps 2-4 in the execution_table.
What does nodelay do when burst queue is used?
With nodelay on, queued burst requests are allowed immediately without delay, as seen in steps 2-4 where requests are allowed right away.
What happens when the burst queue is full and no tokens are available?
Requests are delayed or rejected, as shown in step 5 where burst queue is at max and tokens are zero.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. How many requests are currently in the burst queue?
A3
B1
C2
D0
💡 Hint
Check the 'Burst Queue' column at step 3 in the execution_table.
At which step does the token bucket refill to allow a new request?
AStep 6
BStep 5
CStep 4
DStep 7
💡 Hint
Look at the 'Tokens Available' column for when it changes from 0 to 1.
If nodelay was off, what would happen to burst queued requests?
AThey would be allowed immediately anyway
BThey would be delayed and not allowed immediately
CThey would be rejected immediately
DTokens would refill faster
💡 Hint
Recall nodelay controls immediate processing of burst queued requests as shown in the execution_table.
Concept Snapshot
limit_req_zone defines request rate and token bucket.
limit_req with burst allows extra queued requests beyond tokens.
nodelay sends burst requests immediately without delay.
Without nodelay, burst requests wait for tokens.
Burst queue max size controls how many extra requests can queue.
Requests exceeding burst queue are delayed or rejected.
Full Transcript
This visual execution shows how nginx's limit_req with burst and nodelay options work. Each incoming request checks if tokens are available in the token bucket. If tokens exist, the request is allowed immediately and tokens decrease. If no tokens are available, burst allows extra requests to queue temporarily. When nodelay is on, these burst queued requests are allowed immediately without waiting. The execution table tracks tokens and burst queue size per request. When the burst queue is full and no tokens remain, requests are delayed or rejected. The variable tracker shows tokens and burst queue changes over time. Key moments clarify why burst queue fills and how nodelay affects request handling. The quiz tests understanding of burst queue size, token refill timing, and nodelay behavior. The snapshot summarizes the core nginx rate limiting concepts with burst and nodelay options.

Practice

(1/5)
1. What does the burst option do in nginx rate limiting?
easy
A. Processes all requests without any limit
B. Immediately rejects extra requests beyond the limit
C. Allows extra requests to wait in a queue before being processed
D. Delays all requests by a fixed time

Solution

  1. Step 1: Understand the purpose of burst

    The burst option in nginx allows extra requests that exceed the rate limit to be queued temporarily instead of being rejected immediately.
  2. Step 2: Compare with other options

    Unlike rejecting or delaying all requests, burst specifically queues extra requests to handle traffic spikes smoothly.
  3. Final Answer:

    Allows extra requests to wait in a queue before being processed -> Option C
  4. Quick Check:

    Burst = queue extra requests [OK]
Hint: Burst queues extra requests to handle spikes smoothly [OK]
Common Mistakes:
  • Thinking burst rejects extra requests immediately
  • Confusing burst with fixed delay
  • Assuming burst processes all requests without limit
2. Which is the correct syntax to enable burst with 10 requests and nodelay in nginx?
easy
A. limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10 nodelay;
B. limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10 delay;
C. limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10;
D. limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit nodelay burst=10;

Solution

  1. Step 1: Identify correct order and keywords

    The correct syntax places burst=10 followed by nodelay without extra keywords like delay.
  2. Step 2: Validate syntax correctness

    limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10 nodelay; correctly uses limit_req_zone and limit_req directives with proper parameters and order.
  3. Final Answer:

    limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10 nodelay; -> Option A
  4. Quick Check:

    Syntax with burst=10 and nodelay = limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s; limit_req zone=mylimit burst=10 nodelay; [OK]
Hint: Use burst=number before nodelay in limit_req [OK]
Common Mistakes:
  • Using 'delay' instead of 'nodelay'
  • Placing nodelay before burst
  • Omitting limit_req_zone directive
3. Given this nginx config snippet:
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req zone=one burst=3 nodelay;

What happens if 5 requests arrive instantly from the same IP?
medium
A. All 5 requests are processed immediately
B. First 4 requests processed immediately, 5th rejected
C. First request processed immediately, next 4 delayed
D. Only 1 request processed, others rejected

Solution

  1. Step 1: Understand rate and burst limits

    The rate is 1 request per second, burst allows 3 extra requests queued, and nodelay means queued requests run immediately.
  2. Step 2: Analyze 5 instant requests

    The first request is within rate limit, next 3 fit in burst queue and run immediately due to nodelay, the 5th exceeds burst and is rejected.
  3. Final Answer:

    First 4 requests processed immediately, 5th rejected -> Option B
  4. Quick Check:

    Burst=3 + nodelay means 4 immediate, 5th rejected [OK]
Hint: Burst + nodelay = burst requests processed immediately [OK]
Common Mistakes:
  • Assuming all 5 requests pass immediately
  • Thinking requests after burst are delayed, not rejected
  • Ignoring nodelay effect
4. You configured burst=5 but your nginx still rejects extra requests immediately. What is the likely cause?
medium
A. You forgot to add the nodelay option
B. The limit_req_zone directive is missing
C. The burst value must be less than 5
D. You need to restart nginx twice

Solution

  1. Step 1: Check burst behavior without nodelay

    Without nodelay, burst requests are delayed, not processed immediately, but if delay is too long, clients may see rejections.
  2. Step 2: Identify missing nodelay effect

    If extra requests are rejected immediately despite burst, likely nodelay is missing, causing strict rate enforcement.
  3. Final Answer:

    You forgot to add the nodelay option -> Option A
  4. Quick Check:

    Missing nodelay causes immediate rejection despite burst [OK]
Hint: Add nodelay to process burst requests immediately [OK]
Common Mistakes:
  • Assuming burst alone allows immediate processing
  • Thinking burst must be less than 5
  • Believing multiple restarts fix config issues
5. You want to handle sudden spikes of up to 20 extra requests per second without delay, but reject any beyond that. Which nginx config snippet achieves this?
hard
A. limit_req_zone $binary_remote_addr zone=spike:10m rate=20r/s; limit_req zone=spike burst=5 nodelay;
B. limit_req_zone $binary_remote_addr zone=spike:10m rate=25r/s; limit_req zone=spike burst=0;
C. limit_req_zone $binary_remote_addr zone=spike:10m rate=5r/s; limit_req zone=spike burst=0 nodelay;
D. limit_req_zone $binary_remote_addr zone=spike:10m rate=5r/s; limit_req zone=spike burst=20 nodelay;

Solution

  1. Step 1: Set base rate and burst for spikes

    The base rate is 5 requests per second, and burst=20 allows 20 extra requests queued.
  2. Step 2: Use nodelay to process burst immediately

    Adding nodelay ensures the burst requests are processed right away without delay.
  3. Step 3: Confirm rejection beyond burst

    Requests beyond burst=20 will be rejected, matching the requirement.
  4. Final Answer:

    limit_req_zone $binary_remote_addr zone=spike:10m rate=5r/s; limit_req zone=spike burst=20 nodelay; -> Option D
  5. Quick Check:

    Rate=5r/s + burst=20 + nodelay = limit_req_zone $binary_remote_addr zone=spike:10m rate=5r/s; limit_req zone=spike burst=20 nodelay; [OK]
Hint: Set burst high with nodelay to handle spikes immediately [OK]
Common Mistakes:
  • Setting burst too low for spikes
  • Omitting nodelay causing delays
  • Setting rate too high ignoring burst
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard