rate limiting – Am I misunderstanding nginx’s limit_req?

http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=2r/s;
    limit_req_status 429;
}

server {
    location /ajax {
        limit_req zone=one burst=30 nodelay;
    }

    location / {
        limit_req zone=one burst=5 nodelay;
    }
}

When typing a search term into my site (which fires off an xhttp request with each keystroke) the responses from /ajax quickly go to 429 response code, well before 30 requests.

I think it’s clear what I’m trying to achieve. No more than 2 requests per second, with bursts of up to 5, and bursts of up to 30 if they’re to an /ajax endpoint.

Read more here: Source link