Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upLimit download/upload speeds (throttling) #163
Comments
This comment has been minimized.
This comment has been minimized.
|
+1 |
This comment has been minimized.
This comment has been minimized.
|
+1 ;) |
This comment has been minimized.
This comment has been minimized.
|
Agreed – this feature is useful to limit bandwidth consumption so other apps (like web browsers) can continue to function. (Btw, it doesn't make much sense for the browser version of webtorrent). Though it sounds simple, it's definitely non-trivial to implement. Limiting the speed of a single node.js stream is easy, but making it work across the whole client will take a bit of thinking... |
This comment has been minimized.
This comment has been minimized.
|
Wow, nice! How about naming it |
This comment has been minimized.
This comment has been minimized.
|
Btw, in the picture you posted, the aggregate bandwidth was 410 KB/s. We On Mon Nov 03 2014 at 11:09:51 PM opfl notifications@github.com wrote:
|
This comment has been minimized.
This comment has been minimized.
|
As a noobish system administrator it feels a bit strange to me to use Javascript to limit bandwidth. Maybe it's just a prejudice, but node doesn't strike me as being a good candidate. If it's ok to limit the solution to only unix servers, we could use Ip/Nftables and tc. We could open the stream as a child process, and then the linux kernel could keep track of the process, which is very efficient at doing it.
First we get the PID of the process
then we could use iptables to mark the packet, then Traffic control could shaper on a per PID basis http://lartc.org/howto/lartc.qdisc.filters.html If it's ok I could try to build something concrete |
This comment has been minimized.
This comment has been minimized.
|
@Svenskunganka the only thing we would have to rely on is a unix kernel :P If node does it, I'm sure it would use the kernel too. I dont know any other way to shape traffic. |
This comment has been minimized.
This comment has been minimized.
|
No, iptables is specific to Linux. |
This comment has been minimized.
This comment has been minimized.
|
yes you are right. I'm studying the source to try to come up with a good solution, since I need this, and to better learn this project. ? |
This comment has been minimized.
This comment has been minimized.
|
While dropping packets is perfectly valid, this shaping is best done in the actual code. FWIW here's my approach from Bitford: https://github.com/astro/bitford/blob/master/src/shaper.js |
This comment has been minimized.
This comment has been minimized.
|
Once implemented, will stream backpressure on the read side slow the download speed? |
This comment has been minimized.
This comment has been minimized.
|
Backpressure should go into https://github.com/feross/bittorrent-protocol/ where it doesn't seem to be implemented at this time. That will only become a problem if download speeds exceed CPU power & disk throughput. |
This comment has been minimized.
This comment has been minimized.
|
@astro In the download case yes, but when streaming media it is very common that the download speed greatly exceed the playback speed. For example, if you pipe media into VLC, only a couple seconds of media data will be buffered prior to decoding and playback. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
What happened to this issue? |
This comment has been minimized.
This comment has been minimized.
|
I'm guessing this didn't happen yet? The stream solution that you provided @feross is only for download streams, right? It's no way to control upload. I'm pretty new in webtorrent, is any of the libs to seed providing support for throttling? |
This comment has been minimized.
This comment has been minimized.
|
Implementing this seems hard with the way the event loop is ran. It seems to walk the swarm a lot. |
This comment has been minimized.
This comment has been minimized.
|
I'm working on something similar at work (my application just uploads) and this library works really well: https://github.com/tjgq/node-stream-throttle You can set up a group with an aggregate rate limit and spin off throttles for each stream. I'm working out issues with changing the speed while connections are in-flight, but if I get it sorted, I'd be happy to take a stab at a PR for this. |
This comment has been minimized.
This comment has been minimized.
|
@scotttrinh Yes, that would be much appreciated! |
This comment has been minimized.
This comment has been minimized.
|
Any update on this? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Actually, I just saw #1040. That seems like a reasonable PR for this feature. |
This comment has been minimized.
This comment has been minimized.
|
Hello, I would like to know if this is implemented, and if it is, then how to do it. |
This comment has been minimized.
This comment has been minimized.
|
@abcd9999 Unfortunately I never got around to it. :( |
This comment has been minimized.
This comment has been minimized.
|
This seems to have a very low priority although it would have a great impact. |
It would be cool to be able to limit download/upload speeds.