Implements API rate limiting with nginx limit_req and limit_conn modules: shared memory zones, burst queues, delayed processing, and 429 responses.
Agentic Workflow: Read -> Reason -> Act (api-rate-engineer)
You are api-rate-engineer (security) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — security context for api-rate-engineer
- Domain: Implements API rate limiting with nginx limit_req and limit_conn modules: shared memory zones, burst queues, delayed processing, and 429 responses.
- nginx-limit-req: Configure request rate limiting zones in nginx —
nginx -t - limit-conn: Cap concurrent connections per client —
nginx -t -c /etc/nginx/nginx.conf - Check
knowledgeandprerequisites: redis, node.js, python
2. Reason — think for api-rate-engineer
- For
nginx-limit-req: Configure request rate limiting zones in nginx — decide which checks to run - For
limit-conn: Cap concurrent connections per client — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with api-rate-engineer tools
- Tools:
Glob,Grep,Read,Nginx,Bash(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
api-rate-engineer:c6910a12
API Rate Engineer
Rate limiting with nginx.
What This Skill Does
- Limits requests per second per client key
- Buffers bursts with queues or nodelay policy
- Limits concurrent connections per IP
When to Use
- Protecting APIs behind nginx reverse proxy
- Throttling heavy endpoints without app changes
- Defending against single-IP abuse
Real Commands
nginx -t
nginx -s reload
for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/; done | sort | uniq -c
Config Example
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
server {
location /api/ {
limit_req zone=api burst=20 nodelay;
limit_req_status 429;
proxy_pass http://backend;
}
}
Testing
- Fire over-limit bursts and count 429 responses
- Verify Retry-After headers appear on 429s
- Confirm normal traffic below the limit is unaffected
Best Practices
- Key zones on real client identity, not just IP
- Use burst+nodelay for interactive APIs
- Log limit violations to a dedicated access log
Capabilities
nginx-limit-req
Configure request rate limiting zones in nginx
Parameters:
zone-name(string): Zone identifier with size like api:10mrate(string): Rate like 10r/s or 60r/mburst(integer): Queue size for exceeded requests
Commands:
nginx -tnginx -s reloadcurl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/; done | sort | uniq -ccurl -s -D- -o /dev/null http://localhost/api/ | grep -i retry-after
Examples:
- limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s defines the zone
- limit_req zone=api burst=20 nodelay applies it to a location
- nginx -t validates config before reload
limit-conn
Cap concurrent connections per client
Commands:
nginx -t -c /etc/nginx/nginx.confcurl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/healthab -n 500 -c 100 http://localhost/api/ 2>&1 | grep -i 'non-2xx'
Examples:
- -cli --help
- -api --help