Welcome! Log In Create A New Profile

Advanced

Re: Limit_zone and limit_conn problem.

Maxim Dounin
January 23, 2010 01:32PM
Hello!

On Sat, Jan 23, 2010 at 08:51:29AM +0100, Piotr Karbowski wrote:

> Thanks you for your reply but I still dont understand it. Sometimes it
> seen to work, but sometimes no, no 503 error, multiple files at once
> etc.
>
> I wanna prevent mass downloading files from /specified/ dir but this
> limit_conn dont work as it should. have you any other idea how can I
> limit mass downloading?

Well, I've tried to explain that "multiple files at once" may not
be the same from nginx point of view, and that's why you don't see
503. In the post you linked it's certainly the case.

Try the following test:

http {
limit_zone unique_zone_name $binary_remote_addr 10m;
sendfile on;
sendfile_max_chunk 1m;
...
server {
...
location /download/ {
limit_conn unique_zone_name 1;
}
}
}

Start downloading of something large (e.g. 4G) from /download/.
Make sure it's downloaded via single request and data are flowing
around (netstat & tcpdump are your friends).

Once you are checked the above - try starting another download
from the same ip. It should return 503.

Note well: nginx will process request without switching to another
one until it will be able to fill up socket send buffer. This may
not happen at all if you are testing via fast local connection,
your output_buffers are smaller than socket send buffer, and you
are and not using limit_rate and/or sendfile with
sendfile_max_chunk. So requests will be processed in order by
nginx, and you won't see 503.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Limit_zone and limit_conn problem.

Piotr Karbowski January 22, 2010 03:00PM

Re: Limit_zone and limit_conn problem.

Maxim Dounin January 22, 2010 03:58PM

Re: Limit_zone and limit_conn problem.

Piotr Karbowski January 23, 2010 02:56AM

Re: Limit_zone and limit_conn problem.

Maxim Dounin January 23, 2010 01:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 146
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready