Node.js TCP socket server data buffer ordering

337 views Asked by At

I am streaming data from 50 devices on one network (one single external IP address) over to a Network load balancer on GCP (Google Cloud Platform) which then distributes the traffic to a group of Node.js TCP socket servers (using net module) that process the data.

Each device sends about 200 kilobits of data per second as a single message, and on the server end the data gets segmented into a stream of buffers like:

[Buffer size 1400]
[Buffer size 1400] 
[Buffer size 525]
[...]

Since I am streaming from 50 separate devices, would the data become entangled and out of order since to the load balancer all the data are coming from a single external IP address?

Would something like this happen?

[Buffer size 1400 with data from device A] 
[Buffer size 1400 with data from device B] 
[Buffer size 1400 with data from device A and B]
[...]

If something like this would happen what can I do to still parse the data from each of the 50 devices even though they are all sent from the same network?

I apologize if my question is stupid because I might have missed something fundamental about how TCP/IP works, but I haven't been able to find an answer to this after hours of searching.

0

There are 0 answers