Hi, thanks a lot for responding.
I would like to recompile nginx for testing purposes
with the limit decreased so that I would not have to
use hundreds of IPs to see what happens.
The main question for me to answer would be:
If my size of the zone 1M how many IP addresses
can I have at most and for how long w/o getting
the 503 due to zone memory exhaustion?
2 related question groups:
1. How small do I have to make the allowed memory
so I would exhaust the space with 2/3 ips (I could use
larger data structures like ip + url + some headers of course).
2. To test the expiration behavior to answer the questions:
how does the state expire? Is it saved till a reload or restart?
Does a reload pass the state (copies it) to the new worker?
If my size of the zone 1M how many IP addresses can I have
at most and for how long?
So the node is of type
The definition of this type is this:
On Saturday, October 8, 2016 at 3:27:15 AM UTC+3, rpaprocki wrote:
Hi,
On Friday, October 7, 2016 at 4:15:33 AM UTC-7, Mindaugas Bernatavičius wrote:
Greetings openresty-en group,
I wanted to ask a question related more to nginx, than openresty per se.
One of the modules that is often employed
has the following precaution in the documentation:
If the zone storage is exhausted, the server will return the 503
(Service Temporarily Unavailable) error to all further requests.
It is interesting for me how is the
defined?
All the information needed for the rate limit?
If so, what does it contain - the data structure.
The underlying data structure is a red-black tree. The limt_req_zone directive (
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_zone) allows the user to define the key for a given element inside the zone. The larger the key, the more memory this will take. If you're using the remote IP as the key, the variable $binary_remote_addr is the most efficient way to store this. The value stored is type ngx_uint_t, whichis typedef'd to
uintptr_t.
I have multiple users on the website served by openresty.
Would the zone size be exhausted if the unique IP count
would reach 8K unique IP's in some time frame?
How do I determine the lower bound of the zone?
For example do I need 5m or 20m?
From the docs (assuming you're using $binary_remote_addr as the key):
> 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.