Forum: NGINX limit_req_zone key cache lifetime

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
37336f37559c2cf92aba7620cfeae780?d=identicon&s=25 Chad Hansen (Guest)
on 2016-07-14 21:22
(Received via mailing list)
I'm looking for documentation or explanation for how keys expire in the
limit_req_zone. I have the basic documenations here:

*A client IP address serves as a key. Note that instead of $remote_addr,
the $binary_remote_addr variable is used here.
The $binary_remote_addr variable’s size is always 4 bytes for
IPv4 addresses or 16 bytes for IPv6 addresses. The stored state always
occupies 64 bytes on 32-bit platforms and 128 bytes on 64-bit platforms.
One megabyte zone can keep about 16 thousand 64-byte states or about 8
thousand 128-byte states. If the zone storage is exhausted, the server
will
return the 503 (Service Temporarily Unavailable) error to all further
requests.*

But there's no explanation for how the key cache eventually clears
itself.
Is any available?
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2016-07-14 22:27
(Received via mailing list)
Hello!

On Thu, Jul 14, 2016 at 07:22:06PM +0000, Chad Hansen wrote:

> return the 503 (Service Temporarily Unavailable) error to all further
> requests.*
>
> But there's no explanation for how the key cache eventually clears itself.
> Is any available?

The same page also specifies the algorithm used,
http://nginx.org/en/docs/http/ngx_http_limit_req_m...

: The limitation is done using the “leaky bucket” method.

See https://en.wikipedia.org/wiki/Leaky_bucket for further
details about the algorithm itself.

The algorithm implies that there is no need to store anything for
keys where there are no excessive requests.  Such zero states are
automatically removed by the code when nginx is about to allocate
a new state.

--
Maxim Dounin
http://nginx.org/
37336f37559c2cf92aba7620cfeae780?d=identicon&s=25 Chad Hansen (Guest)
on 2016-07-14 22:31
(Received via mailing list)
Great, thank you!
This topic is locked and can not be replied to.