Marcio Cunha

Slow network on Linux? How to find bottlenecks with ss

Is your application lagging and you suspect the network? Learn how to use ss and netstat to inspect sockets, find retransmissions, and clear bottlenecks in Linux.

Marcio Cunha•2 min
Also available in:PortuguêsEspañol
Summary
  • The ss command has replaced netstat due to its superior speed and deep kernel socket visibility.
  • Connection states like SYN-RECV or CLOSE-WAIT often point to TCP negotiation or resource management issues.
  • High values in Recv-Q or Send-Q indicate that your application cannot keep up with network packet processing.
  • Excessive retransmissions found via socket statistics are strong indicators of physical network congestion or packet loss.
  • Command-line inspection remains the most reliable way to debug connectivity without overhead in production environments.

Why does your network seem slow on Linux?

When a distributed application starts lagging, the first suspect is usually the database or high CPU usage, but the network is a silent component that often hides the real bottleneck. On Linux, communication between services happens through sockets—endpoints that allow data exchange between processes. If your application is slow, your sockets might be queuing packets, hanging in wait states, or suffering from retransmissions, as we discussed when analyzing high CPU bottlenecks on Linux.

Understanding the ss command as the netstat successor

For years, netstat was the standard tool, but today it is considered legacy. The ss (socket statistics) command performs the same job much faster because it extracts information directly from the system kernel. While netstat traverses the /proc directory, ss uses the netlink interface, allowing you to view thousands of connections in milliseconds. If you are investigating physical issues, remember to check for faulty cables and switches before blaming the software layer.

How to identify problematic connections with ss

To inspect active connections, the most practical command is ss -tunap. Each letter represents an option: t for TCP, u for UDP, n to avoid resolving names (making output instant), a for all connections, and p to show the process owning that socket. Look for states like SYN-RECV, which indicates the server received a request but cannot complete the handshake, or CLOSE-WAIT, a sign that the application is not closing connections correctly, potentially leading to file descriptor exhaustion.

Interpreting network queues

One of the biggest indicators of a bottleneck is the Recv-Q (receive queue) and Send-Q (send queue). The Recv-Q represents packets that reached the server but haven't been read by the application yet. If this value is high and constant, your application is too slow to process incoming traffic. A high Send-Q means the server is pushing data faster than the client or the network can absorb. In complex scenarios, you might need to use tcpdump to understand exactly what is moving through those queues.

Advanced diagnostics with socket statistics

For a deeper analysis, use ss -tie. The -i option displays internal TCP info, like RTT (Round Trip Time), the time a packet takes to go and return. If the RTT is high, latency might be in the physical path. The -e flag shows extended details like connection lifetime and retransmission statistics. Frequent retransmissions indicate packet loss on the network, a clear sign that you need to inspect infrastructure, such as unstable links or collisions on switches.

Conclusion

Mastering ss and netstat is essential for any engineer maintaining distributed applications under load. Identifying whether the bottleneck lies within the application (not reading fast enough) or the network (dropping packets) saves hours of debugging.

Whenever you encounter strange network behavior, start with basic connection counting before moving to complex captures. With this visibility, you stop guessing and start making technical decisions based on real data.