Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit_traffic_rate_zone rate $remote_addr not limiting by IP #4

Open
ryanrbftp opened this issue May 13, 2013 · 6 comments
Open

limit_traffic_rate_zone rate $remote_addr not limiting by IP #4

ryanrbftp opened this issue May 13, 2013 · 6 comments

Comments

@ryanrbftp
Copy link

I have just installed a fresh copy of Nginx for our HTTP download file server. This module is amazing (when working properly) and just what we are looking for.

However, while we have managed to configure it to limit per connection - if a user from the same IP opens up another connection then the download speed is not shared - they get a full speed connection again.

For example, we have set the speed limit to 20kb/s... if a user connects with one connection goes to download a file with one thread, that's fine and speed is limited. But if they open multiple connections (for example a download software), they can achieve many 20kb/s connections - for example 5 connections brings 100kb/s.

How can I limit the connection speed across all connections from the same IP?

Current config:

limit_traffic_rate_zone rate $remote_addr 32m;
location / {
                limit_traffic_rate  rate 20k;
            }
@bigplum
Copy link
Owner

bigplum commented May 14, 2013

I have just tested this module with nginx-1.4.1, and it worked well.

So could you post the accesslog and debug log here to see what happened?

@ryanrbftp
Copy link
Author

We too are using a fresh copy of 1.4.1.

We have disabled accesslog and debug log. Is there any other way of diagnosing this?

@ryanrbftp
Copy link
Author

Okay, I have enabled debugging for connections from my IP only.

See from the screenshot 10x connections brings 200kb/s instead of the 20kb/s as stated in the config. Each connection has 20kb/s.
screen shot 2013-05-14 at 12 05 28

See error.log (http://pastebin.com/YKVqH6Hm) with debug for my IP. I opened 10 connections to a single file in this example.

@bigplum
Copy link
Owner

bigplum commented May 15, 2013

I've pushed a path to fix this issue. And now I think it will work correctly.

This issue had been found before, but I forgot to sync the code to github. So sorry for that.

@ryanrbftp
Copy link
Author

Thank you very much! This seems to have fixed it.

However, a little bug...

When downloading two files at the same time - the first download gets priority of speed while the second download gets less priority. See screenshot.

screen shot 2013-05-15 at 11 53 02

Why is the speed not shared equally - i.e. 10kb/s each? Is the speed set once at initial connection or is updated live throughout the streaming process? Also, if the first download is canceled and only one connection is open (the second one) - the transfer speed does not increase up to 20kb/s.

Update: maybe it does increase but very, very slowly. Is there any way to update the refresh speed?

@bigplum
Copy link
Owner

bigplum commented May 16, 2013

This module use nginx core variable "limit_rate" to limit rate. Because of the limitation of "limit_rate", we can not distribute equally and smoothly. There were some discussion about this topic. Please refer to the post:

http://forum.nginx.org/read.php?2,159398,159515#msg-159515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants