Bad throughput for single tcp connections

tcp

I have a server with a Gigabit Uplink, and testing with iperf3 with 100 parallel connections i get at least 600 MBit/s, depending on the other server (i tried some public test servers).
But when i run iperf3 with one connection i get 10-15 MBit/s, with two 20-30 MBit/s and so on.

I do not have very complicated iptables rules and no other idea, why it is so slow. What can be the limiting factor for single tcp connections, that they are 10 times slower than the possible bandwidth?

Best Answer

I finally found the cause of the problem.

I had some flask webapp, which uses redis to stream events to the user. When the user disconnected, the app kept the redis pubsub connection alive, without reading data anymore.

This leads to a long Send-Q/Recv-Q, which apparently cause the tcp stack to slow down and produce kernel warnings: "TCP: out of memory -- consider tuning tcp_mem".

  • Short term fix: Kill the processes with the long packet queues.
  • Long term solution: Fixing the misbehaving programs.