Search code examples
node.jsvideo-streamingsocket.iobandwidth

How to monitor/calculate bandwidth usage of a NodeJS server?


Ok so in some spare time i have developed a nodejs/socketio application that streams video but i would like to know what sort of stats its running at, i have my activity monitor running and currently with 2 users sending each other data streams and the stats are as follows:

%CPU: 6.0
Threads: 5
Real Memory: 59.6mb

How can i work out the total MB/GB of data sent on the server?


Solution

  • My suggestion would be to add a counter in your app.

    You should be able to add something like the following:

    socket.on('message', function(message, callback) { myCounter += sizeof(message); })

    The key here would be identifying the sizeof the message you are sending. If it's a buffer, then you can just count bytes. I'm not clear what type of packing they use when sending JSON.