Search code examples
node.jsbandwidth

How to limit node.js bandwidth?


Is it possible to limit bandwidth for a certain node.js process? It appears that pause/resume on socket data doesn't actually affect the download speed.

I've also tried trickle to no avail: trickle -d 1 -u 1 node band.js, shows the same speed as without trickle.


Solution

  • I have the same problem on this. I posted a issue on github project libuv, it's the core of event system of Node.js, since I believe that's the cause why trickle does not work. (https://github.com/joyent/libuv/issues/844)

    Thanks to response from bnoordhuis, the reason trickle can't work is because of libuv use system_call to use system call directly, not by calling glibc. However, trickle only wrap glibc functions to add bandwidth limitation support.

    I haven't found a perfect solution yet, but you can try these:

    1. pfSense: a freebsd-based standalone firewall with bandwidth limitation support
    2. netbrake: like trickle, worked with Node.js, but it's not accurate, and need to limit upload and download bandwidth together
    3. trickle: if you are trying to do some experiments, you can try to use trickle on the client side, since trickle is worked with curl