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

frequency limit on connections #189

Closed
oribrost opened this issue Apr 8, 2012 · 8 comments
Closed

frequency limit on connections #189

oribrost opened this issue Apr 8, 2012 · 8 comments
Milestone

Comments

@oribrost
Copy link
Contributor

oribrost commented Apr 8, 2012

Cowboy currently features a max connection limit, but it doesn't allow throttling the number of requests per a given time interval. It would be useful to allow specifying two variables MaxConnPerPeriod and PeriodInSec such that more than MaxConnPerPeriod per PeriodInSec is not allowed. Ideally this would be implemented in 2 versions, one in cowboy_listener, and an approximate per listener version to be used if cowboy_listener is disabled (see issue #188).

@oribrost
Copy link
Contributor Author

oribrost commented Apr 8, 2012

tagging @nivertech

@oribrost
Copy link
Contributor Author

oribrost commented Apr 8, 2012

We implemented this in cowboy_acceptor.erl in nivertech@9e087b8

@ghost
Copy link

ghost commented Apr 8, 2012

I see some value in adding this. I disagree with the implementation which handles it by closing the newly accepted connection instead of not accepting it in the first place.

@nivertech
Copy link

Not accepting new connections even better.
Can you point us in the right direction?
The only way I know is playing with accept queue length.

On Sun, Apr 8, 2012 at 7:57 PM, Magnus Klaar <
reply@reply.github.com

wrote:

I see some value in adding this. I disagree with the implementation which
handles it by closing the newly accepted connection instead of not
accepting it in the first place.


Reply to this email directly or view it on GitHub:
#189 (comment)

@ghost
Copy link

ghost commented Apr 8, 2012

When we did rate limiting in etorrent we chose a strategy where we introduce a wait time based on the current rate and the allowed rate. In very vague terms, given a maximum rate of 10000 accepts per second and 100 acceptors and assuming that it takes 0ms to accept and handle a connection. Each acceptor must sleep for 10ms before calling accept/2 again.

@essen
Copy link
Member

essen commented Apr 10, 2012

If my async-accept branch goes in (that won't be until after 0.6 though), then it should be much easier to implement this one.

@ghost
Copy link

ghost commented Apr 10, 2012

Yes, since this is one many possible takes on hooking in load regulation at the acceptor level, it's better to make an extension point for this over hard coding in one solution.

@essen
Copy link
Member

essen commented Apr 16, 2012

Closing this, to be continued in Ranch: ninenines/ranch#5

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

3 participants