In this link I see the nginx
says:
Zone – Defines the shared memory zone used to store the state of each IP address and how often it has accessed a request‑limited URL. Keeping the information in shared memory means it can be shared among the NGINX worker processes. The definition has two parts: the zone name identified by the
zone= keyword
, and the size following the colon. State information for about 16,000 IP addresses takes 1 ;megabyte, so our zone can store about 160,000 addresses.
My questions and what I don’t understand are the following:
- How long it takes for
nginx
to clear the memory of stored IP addresses?
In this part, it says:
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
The 10m
by the previous definition, it means 1,600,000 IP addresses.
- For how long the
nginx
stores these IP addresses and how it clears them?
The purpose of this question is this:
I set a rate limit like this:
limit_req_zone $binary_remote_addr zone=mylimit:1m rate=2r/s;
I create a very simple html
page which has one request only. So technically I can refresh this page 2 times per second and for the 3rd time to refresh, I should be faced with an error like 503 or 429.
Up to this point, everything is fine. But after a couple of seconds 15 seconds waiting and doing nothing, I refresh the page but I still get 503 or 429 error.
I even did systemctl reload nginx
but I still see error page. Then I did systemctl restart nginx
but nothing changed.
Am I doing anything wrong here? Did I misunderstood anything here? Or there are some topics or subjects I don’t know?