Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure TCP back pressure?

I am trying to investigate a performance issue with code that publishes data to a server over a TCP socket. One hypothesis is that the publisher is experiencing back pressure at the socket level. Is there a way to get a back-pressure metric from the operating system?

I'm sure the answer is specific to the operating system. In my case, I am using Linux.

like image 847
sam.bishop Avatar asked Jul 19 '16 16:07

sam.bishop


2 Answers

Look at the window sizes with tcpdump: https://en.wikipedia.org/wiki/TCP_tuning#Window_size

It should be going down if the other end is not keeping up with the traffic.

like image 132
Karol Nowak Avatar answered Oct 28 '22 15:10

Karol Nowak


As @karol-nowak said, you can use tcpdump to inspect the field window sent on every TCP packet (here the structure of a TCP packet).

I share an example where a server starts to process slower:

Context: a server is running at port 8080. It streams files from a client to an external server. The path between the proxy and the external server is slow because is limited by the Internet connection. The path between the client and the proxy is fast and is limited by the speed the proxy is able to process. It's important to note that the proxy simply forwards the incoming request to the outgoing request to the external server by stream processing, without allocating all the content of the incoming file on the heap.

Inspecting the path between the client and the proxy (the faster path):

sudo tcpdump -i any -nn "src port 8080"

Where:

  • -i any -> any network interface
  • -nn -> don't convert addresses to names
  • "src port 8080" -> select only packets that come from port 8080 (where the proxy is listening at)

Partial output from the above tcpdump:

enter image description here

In the win column you can see how the proxy started to run out of space to buffer the client packets, in this case sent from port 63447, slowing down sending packets from the client (it's notable the gap between 14:10:46 and 14:10:51)

like image 41
cspinetta Avatar answered Oct 28 '22 17:10

cspinetta