Apache APISIX Limit Count Not Enforcing
You encounter a apisix configuration issue that prevents your workflow from completing. This guide walks through the fix step by step.
Wrong ❌
{
"plugins": {
"limit-count": {
"count": 100,
"time_window": 60,
"rejected_code": 429
}
}
}
Wrong Output
Limit count not working. All requests pass through. No 429 returned. Default key (remote_addr) works but may not be specific enough.
Right ✅
{
"plugins": {
"limit-count": {
"count": 100,
"time_window": 60,
"rejected_code": 429,
"policy": "local",
"key": "consumer_name",
"key_type": "var",
"allow_degradation": false
}
}
}
Right Output
Rate limit enforced. 100 requests per 60s window. 429 returned after exceeding. Consumer-based key tracking.
Prevention
- Set the key to consumer_name for authenticated Rate Limiting.
- Use policy: local for single-node, redis for cluster.
- Set allow_degradation: false to fail closed on redis failure.
- Set meaningful count and time_window values.
- Test with a load testing tool to verify limits.
DodaTech applies similar defensive patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro infrastructure for production reliability.
Common Mistakes with limit count
- Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
These mistakes appear frequently in real-world APISIX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
This quick fix is part of the DodaTech infrastructure engineering series. Learn more at DodaTech tutorials.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro