Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 730
ChrisMJ Avatar asked Aug 16 '12 14:08

ChrisMJ


People also ask

How do I check my bandwidth utilization on my server?

To keep track of the bandwidth usage of a Windows Server in real-time, you can use the SolarWinds Bandwidth Gauges. This tool is part of the Engineer's Toolset and you can set it up to monitor any of the devices on your network that you have identified with SNMP.

How do I monitor bandwidth utilization?

One way to assess a network's bandwidth usage is to run a network internet speed test. This allows you to view your network download and upload speeds in near real time. Running a test like this during several points in the day can give a general idea of overall usage and help with measuring bandwidth usage trends.

How does SNMP calculate bandwidth utilization?

Bandwidth utilization is calculated via SNMP polls. Furthermore, it is calculated using the difference between two timestamps. Therefore, the calculations to manually perform this are considered time consuming.


1 Answers

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.

like image 109
Gates VP Avatar answered Oct 02 '22 04:10

Gates VP