Memory usage for the ngx_http_limit_req_module module

Francis Daly francis at daoine.org
Thu Sep 17 19:38:50 UTC 2015


On Thu, Sep 17, 2015 at 12:19:31PM -0400, slowhand84 wrote:

Hi there,

>    I'm using the "nxg_http_limit_req" module to limit the service usage.
> I've a questions about the "limit_req_zone" directive: how can I set the
> correct size for the zone?
> In docs I see that "One megabyte zone can keep about 16 thousand 64-byte
> states", how can I know how much memory is necessary for each state? Is the
> state a request in the "leaky bucket"?

Without checking the source, I'd suggest that the state is probably close to
"a fixed size, plus the size of the key that you choose".

And the documentation suggests that using $binary_remote_addr as a key,
the state is about 64 bytes. $binary_remote_addr is 4 or 16 bytes, probably.

If you want the real number in your deployment, set a zone of size (say)
1kB; make counted requests with unique keys, and see which one gives
you the first "zone is full" (503) response.

If the state is 64 bytes, you'd expect the 17th request to fail.

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list