On Saturday 13 September 2014 18:07:31 matt_l wrote:
is completely equivalent to
limit_req_zone $binary_remote_addr zone=two:20m rate=10r/s;
I am thinking that one would want to have multiple limit_req_zone if one
wants different rates and zone sizes?
Well, no. It’s not an equivalent to one zone with bigger size.
Can you see the difference between this config:
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=two:10m rate=10r/s;
server {
server_name one.example.org;
limit_rate zone=one burst=10;
}
server {
server_name two.example.org;
limit_rate zone=two burst=10;
}
and this one:
limit_req_zone $binary_remote_addr zone=both:20m rate=10r/s;
server {
server_name one.example.org;
limit_rate zone=both burst=10;
}
server {
server_name two.example.org;
limit_rate zone=both burst=10;
}
?
With the first configuration a client is able to request
one.example.org and two.example.org with up to 10 rps at
the same time. But with the last one the limitation is
shared between servers, since they share the same limit
zone.
On a separate note, how does one decides the size needed for zone?
A quote from Module ngx_http_limit_req_module
| A client IP address serves as a key. Note that instead of
| $remote_addr, the $binary_remote_addr variable is used here,
| that allows decreasing the state size down to 64 bytes.
| One megabyte zone can keep about 16 thousand 64-byte states.
wbr, Valentin V. Bartenev