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

Use ThrottleGroup to throttle proxy throughput #46

Closed
nerdbeere opened this issue Jul 15, 2015 · 8 comments
Closed

Use ThrottleGroup to throttle proxy throughput #46

nerdbeere opened this issue Jul 15, 2015 · 8 comments

Comments

@nerdbeere
Copy link
Contributor

Me again with another feature request. :)
I'd like to implement a throttling feature in james (which is basically a frontend for hoxy) as mentioned here. But currently request.slow and response.slow only throttle per request.
What I would need is throttling on proxy level, something like proxy.slowUpstream(rate) and proxy.slowDownstream.

After looking into the source I found out that stream-throttle is used in hoxy which has a feature called ThrottleGroup. This might make it easy to implement slowing on proxy level.

@greim
Copy link
Owner

greim commented Jul 16, 2015

Thanks. I hadn't thought of this before, but now that you mention it it seems obvious :)

@greim greim added 2.1 and removed 2.1 labels Jul 16, 2015
@greim
Copy link
Owner

greim commented Jul 19, 2015

Hmm. Should uploads and downloads be independent throttle groups? Presumably yes since most internet connections (in the US at least) are faster down than up. Maybe like this?

new hoxy.Proxy({
  slow: {
    up: { rate: 10000, latency: 30 },
    down: { rate: 100000, latency: 20 },
  }
})

@greim
Copy link
Owner

greim commented Jul 19, 2015

I'm thinking maybe rather something like this:

new hoxy.Proxy({
  slow: {

    // bottlenecks all throughput to this speed
    rate: 10000,

    // delays responses by a certain amount
    latency: 30,

    // bottlenecks all uploads to this speed
    // overrides "rate" above
    up: 10000,

    // bottlenecks all downloads to this speed
    // overrides "rate" above
    down: 100000,
  }
})

@greim
Copy link
Owner

greim commented Jul 19, 2015

Published as 2.0.0. Let me know how it works.

@greim greim closed this as completed Jul 19, 2015
@nerdbeere
Copy link
Contributor Author

Awesome, thanks!
But I think it would make sense to have getters and setters for both up and downstream.
If you point me in the right direction, maybe I an come up with a pull request.

@greim
Copy link
Owner

greim commented Jul 22, 2015

I see. Would it be helpful to have setSlow(opts) and getSlow() methods, which set and get an object having the same structure as the one passed to the constructor? (e.g. { rate, latency, up, down })

@greim greim reopened this Jul 22, 2015
@nerdbeere
Copy link
Contributor Author

That'd be perfect

@greim
Copy link
Owner

greim commented Jul 25, 2015

Added and published in v2.3.0.

@greim greim closed this as completed Jul 25, 2015
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