Skip to content
Linux system performance · Chapter 14 of 21 Day 12: Network II – saturation: interrupts, queues and conntrack

Day 12: Network II – saturation: interrupts, queues and conntrack

Goal: see where a server with many connections hits its limits first – the CPU for network work, the queue for new connections or the kernel’s connection table – and prove each of these limits · Duration: about 3 hours · Prerequisite: Day 0–11

Where we start

No fault from Day 11 is active on last1 any more, and wrk is installed there.

# on last1
tc qdisc show dev eth0
  • tc qdisc show shows the queue (queueing discipline) of a network card.

Expected:

qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64 

fq_codel is the default. If it says netem, the delay from Day 11 is still active; remove it with sudo tc qdisc del dev eth0 root.

# on last1
wrk -v

Expected (excerpt – the first line):

wrk debian/4.1.0-4build2 [epoll] Copyright (C) 2012 Will Glozer

Introduction

Yesterday was about a single connection and the path in between. Today is about the server that has to serve many connections at the same time. Before its application reaches its limits, there are several places in the kernel where work can wait or be dropped – and they show up in no application log.

You look at three of them: first, the CPU time the kernel needs for network packets, and which CPUs it falls on. Second, the queue for new connections of a listening socket – if it overflows, clients wait seconds for a connection even though the server could serve them in milliseconds. Third, the connection table (conntrack) that Linux keeps as soon as a firewall works with states. If it is full, the kernel drops packets – and the only hint is in the kernel log.

Today you learn:

  • to see the network card’s interrupts and softirqs per CPU,
  • to create HTTP load with wrk and read the result,
  • to read a listening socket’s queue with ss -lnt and count overflows with nstat,
  • to understand why a full backlog delays connections by seconds,
  • what conntrack is, when it is active and how to recognize a full table,
  • to read the limit nf_conntrack_max and the states in the table.

Background

The picture for today: a restaurant in the evening

Think of perf1 as a restaurant; the connections are guests.

  • The network card is the door with a doorbell. Every packet rings (interrupt). If the restaurant has only one door and one waiter who opens it, all the opening falls to this one waiter – on perf1 that is CPU 2.
  • The accept queue is the waiting area with chairs. The reception (the kernel) greets new guests and seats them on a chair until a table is free (accept()). When all chairs are taken, nobody else is let in. The guest leaves, comes back after 1 second, then after 2, after 4 …
  • conntrack is the guest book at the entrance. As soon as the landlord wants to know who has been there, the reception enters every guest – and only crosses them out 120 seconds after they leave. When the book is full, nobody gets in, even though all the tables inside are free.

The terms

Term Meaning in the picture
interrupt the network card’s signal to a CPU: a packet has arrived doorbell
softirq NET_RX the actual work on the packet (IP, TCP) in the kernel, usually on the same CPU opening the door, asking the guest in
RSS / RPS distributing packets over several CPUs: in hardware (RSS) or in software (RPS) several doors / a second waiter at the door
accept queue fully established connections the application has not picked up yet chairs in the waiting area
backlog, somaxconn size of this queue: the smaller of the application’s value and the kernel limit number of chairs
SYN retry the client asks again after 1, 2, 4 … seconds guest comes back later
conntrack table of all connections as soon as a rule asks about the state guest book
nf_conntrack_max maximum number of entries pages in the guest book

Remember: A server can fail at the door – with an overloaded CPU, too few chairs or a full guest book – before the application even sees a request.

Interrupts, softirqs and network card queues

When a packet arrives, the network card triggers an interrupt on a CPU. The actual work – passing the packet through IP and TCP – is then done by the kernel in a softirq (NET_RX), usually on the same CPU. If a network card has only one receive queue, this work lands on one CPU. Modern cards have several queues and distribute the packets over the CPUs by hash (RSS, Receive Side Scaling). Where the hardware cannot do that, the kernel can imitate it in software: RPS (Receive Packet Steering), configured via /sys/class/net/eth0/queues/rx-0/rps_cpus.

The queue for new connections

A server opens a socket and calls listen(backlog). When a connection request (SYN) arrives, the kernel performs the handshake itself and puts the finished connection into the accept queue. Only when the application calls accept() does it pick it up there. The length of this queue is the minimum of the application’s backlog and net.core.somaxconn (on Ubuntu 24.04: 4096).

If the queue is full, the kernel drops new connection requests (or answers with SYN cookies). The client hears nothing, waits and sends its SYN again – after 1 second, then after another 2, 4, 8 seconds. So an overflow turns a one-millisecond connection into one of seconds. For listening sockets, ss -lnt shows the current length in Recv-Q and the maximum in Send-Q.

conntrack

As soon as a firewall rule asks about the state of a connection (ct state established), the kernel must know every connection: it keeps them in the connection tracking table. This also happens through NAT, Docker, Kubernetes networking and many firewall tools. Each entry lives as long as the state dictates – a closed TCP connection in the state TIME_WAIT for another 120 seconds. The table has a fixed maximum size, net.netfilter.nf_conntrack_max. When it is full, the kernel drops packets of new connections and writes nf_conntrack: table full, dropping packet to the log.

On a freshly installed Ubuntu without a firewall, conntrack is not even loaded. As soon as someone sets up a stateful rule, it is there.

Drill 1: HTTP load and network work per CPU

Where you are: in two terminals – perf1 and last1.

What you have afterwards: a web server on perf1 under load, and seen on which CPUs the network work lands.

Step 1 – Install nginx. A real web server as the target for the load:

# on perf1
sudo apt-get install -y nginx
# on perf1
nginx -v

Expected:

nginx version: nginx/1.24.0 (Ubuntu)
# on perf1
systemctl is-active nginx

Expected:

active
# on perf1
curl -s -o /dev/null -w "%{http_code}\n" http://localhost/
  • -s silent, -o /dev/null throw the page away, -w "%{http_code}\n" only print the HTTP status.

Expected:

200

nginx starts with one worker process per CPU and serves the default page.

Step 2 – How many doors does the network card have?

# on perf1
ethtool -l eth0
  • ethtool -l shows the number of queues (channels) of a network card.

Expected (excerpt – the first six lines):

Channel parameters for eth0:
Pre-set maximums:
RX:     n/a
TX:     n/a
Other:      n/a
Combined:   1

One queue (Combined: 1) – one door.

Step 3 – Who hears the doorbell? /proc/interrupts counts every interrupt per CPU. perf1’s network card is the virtio device virtio2 (Day 2: virtio_net virtio2 eth0 in dmesg).

# on perf1
cat /proc/interrupts

Expected (excerpt – the header and the lines with virtio2, cut off on the right):

           CPU0       CPU1       CPU2       CPU3
 33:          0          0          0          0  PCI-MSIX-0000:00:12.0   0-edge      virtio2-config
 34:          0          0     431521          0  PCI-MSIX-0000:00:12.0   1-edge      virtio2-input.0
 35:          0          0          0     370123  PCI-MSIX-0000:00:12.0   2-edge      virtio2-output.0

All receive interrupts (input.0) land on CPU 2, all send interrupts (output.0) on CPU 3.

Step 4 – Would a second waiter help?

# on perf1
cat /sys/class/net/eth0/queues/rx-0/rps_cpus
  • rps_cpus is a bitmask of the CPUs RPS may distribute to.

Expected:

0

0 means: RPS is off.

Step 5 – Load. On last1 you start 40 seconds of HTTP load with 200 concurrent connections:

# on last1
wrk -t4 -c200 -d40s http://perf1/
  • wrk is an HTTP load generator. -t4 four threads, -c200 200 open connections, -d40s 40 seconds. The connections stay open (keep-alive); many requests go over each one.

Step 6 – The CPUs under load. While it runs, on perf1:

# on perf1
mpstat -P ALL 2 1
  • -P ALL each CPU separately, 2 1 once over two seconds.

Expected (excerpt – the Average lines):

Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
Average:     all   30.55    0.00   55.74    0.25    0.00    9.10    2.74    0.00    0.00    1.62
Average:       0   33.83    0.00   62.19    0.50    0.00    0.00    2.49    0.00    0.00    1.00
Average:       1   32.84    0.00   60.20    0.00    0.00    0.00    3.98    0.00    0.00    2.99
Average:       2   23.50    0.00   44.50    0.00    0.00   27.50    2.50    0.00    0.00    2.00
Average:       3   32.00    0.00   56.00    0.50    0.00    9.00    2.00    0.00    0.00    0.50
Column Value Meaning
%idle below 3 all CPUs are full
%sys 45–62 a lot of work in the kernel: sending, receiving, system calls
%soft 27.5 on CPU 2, 9 on CPU 3, otherwise 0 network work only occurs where the interrupts land

Step 7 – Where does the network work occur? /proc/softirqs counts softirqs per CPU and type. Read the file twice, about two seconds apart:

# on perf1
cat /proc/softirqs
# on perf1
cat /proc/softirqs

Expected (excerpt – the NET_RX line from both readings):

      NET_RX:        304        311     463568     422940
      NET_RX:        304        311     476030     444681

12,462 were added on CPU 2, 21,741 on CPU 3 – none on CPU 0 and 1.

Step 8 – Who uses the CPU?

# on perf1
pidstat -u 1 1

Expected (excerpt – the header and the nginx lines):

14:33:45      UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
14:33:46       33      8289   27.36   63.21    0.00    0.94   90.57     1  nginx
14:33:46       33      8290   23.58   66.98    0.00    1.89   90.57     2  nginx
14:33:46       33      8291   30.19   62.26    0.00    0.94   92.45     1  nginx
14:33:46       33      8292   28.30   63.21    0.00    0.94   91.51     3  nginx

Four nginx workers with over 90 % CPU each, two thirds of it in the kernel.

Step 9 – wrk’s result. At the end on last1:

  4 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.44ms    2.96ms  47.92ms   76.26%
    Req/Sec     7.50k     1.24k   14.15k    70.98%
  1194469 requests in 40.07s, 0.96GB read
Requests/sec:  29811.09
Transfer/sec:     24.51MB

Just under 30,000 requests per second, average latency 6.4 ms, maximum 48 ms.

What you see: Today the bottleneck is the web server itself, not the network work. But the network work only falls on CPU 2 and 3. If the load were higher and the application lighter, CPU 2 would be the first to be full while the others still have room – the picture in which RPS or a network card with several queues helps.

Remember: One door, one waiter: with one queue, the network work lands on one CPU. %soft per CPU and /proc/softirqs show whether it becomes the bottleneck.

Save your progress? Sign up for free

Drill 2: The queue for new connections overflows

Where you are: in two terminals – perf1 and last1.

What you have afterwards: a server whose accept queue overflows, the counters for it, and measured what a client notices.

Step 1 – A slow server. A small Python program that serves connections only one after the other and needs 20 ms for each:

# on perf1
mkdir -p ~/tag12
# on perf1
nano ~/tag12/langsam.py

Content (nano as on Day 0: Ctrl+O and Enter saves, Ctrl+X exits):

~/tag12/langsam.py new file
import socket, time

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("0.0.0.0", 9000))
s.listen(8)                                   # Warteschlange für neue Verbindungen: 8
while True:
    verbindung, _ = s.accept()
    time.sleep(0.02)                          # 20 ms "Arbeit" pro Anfrage, eine nach der anderen
    verbindung.sendall(b"HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\nok")
    verbindung.close()
  • socket.socket(…) creates a TCP socket, SO_REUSEADDR allows a quick restart on the same port, bind binds it to port 9000 on all addresses.
  • s.listen(8) – the accept queue holds 8 connections: eight chairs (the comment says: “queue for new connections: 8”).
  • The loop is the program itself – you do not type it into the shell. It picks up a connection with accept(), “works” for 20 ms, sends a minimal HTTP response and closes.

Step 2 – Start it as a service.

# on perf1
sudo systemd-run --unit=langsam -p User=ubuntu python3 /home/ubuntu/tag12/langsam.py
  • systemd-run starts the program as a transient service langsam.service (Day 15 goes deeper), -p User=ubuntu as the user ubuntu.

Expected:

Running as unit: langsam.service; invocation ID: b8d156d2e85b42329f897b43c9c5f63d

Step 3 – The empty chairs.

# on perf1
ss -ltn sport = :9000
  • -l listening sockets, -t TCP, -n numbers instead of names, sport = :9000 only source port 9000.

Expected:

State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      8            0.0.0.0:9000      0.0.0.0:*

For a listening socket, Send-Q is the size of the queue (8), Recv-Q its current fill level (0).

Step 4 – Counters to zero. nstat shows the kernel’s network counters since the last call. -n sets the starting point without printing anything:

# on perf1
nstat -n

Step 5 – Load with 100 concurrent connections.

# on last1
wrk -t2 -c100 -d30s --timeout 5s http://perf1:9000/
  • --timeout 5s waits up to five seconds for a response before wrk counts it as a timeout.

Step 6 – The chairs under load. After about ten seconds on perf1:

# on perf1
ss -ltn sport = :9000

Expected:

State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 9      8            0.0.0.0:9000      0.0.0.0:*

Recv-Q 9 with Send-Q 8 – the queue is full (the kernel allows one connection more than the value says).

Step 7 – How often was someone turned away?

# on perf1
nstat

Expected (excerpt – look for the lines TcpPassiveOpens, SyncookiesSent, ListenOverflows and ListenDrops):

TcpPassiveOpens                 470                0.0
TcpExtSyncookiesSent            194                0.0
TcpExtListenOverflows           839                0.0
TcpExtListenDrops               839                0.0
Counter Value Meaning
TcpPassiveOpens 470 accepted connections
TcpExtListenOverflows 839 this often the queue was full
TcpExtListenDrops 839 this many connection requests were dropped
TcpExtSyncookiesSent 194 emergency measure: connection accepted without room in the queue

Step 8 – What a client notices. Run this command three times in a row:

# on perf1
curl -s -o /dev/null -w "%{time_connect} %{time_total}\n" --max-time 10 http://localhost:9000/
  • %{time_connect} time until the connection is established, %{time_total} total time, both in seconds; --max-time 10 aborts after ten seconds.

Expected (three runs):

3.057352 3.258619
0.000658 0.191095
0.000644 0.196319

The first curl needed 3.06 seconds just to establish the connection: its SYN was dropped twice and repeated after 1 and another 2 seconds. The other two were lucky and got through in under a millisecond, but waited 190 ms on their chair until the server served them.

Step 9 – wrk’s result. On last1:

  2 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   210.37ms  149.79ms   3.65s    99.52%
    Req/Sec    29.57     17.92    50.00     42.12%
  1452 requests in 30.09s, 56.72KB read
  Socket errors: connect 0, read 5, write 0, timeout 5
Requests/sec:     48.25
Transfer/sec:      1.88KB

48 requests per second – exactly 1 ÷ 20 ms, the capacity of a server that handles one request after the other. Maximum latency 3.65 seconds: the SYN retries.

What helps? A larger backlog (listen(1024)) removes the jumps of seconds at connection setup – the connections then wait on chairs instead of outside. It changes nothing about the throughput of 48 per second. For that the server needs parallelism: several processes or threads that call accept() at the same time. The backlog is a buffer for peaks, not a substitute for capacity.

Step 10 – Clean up.

# on perf1
sudo systemctl stop langsam
# on perf1
sudo systemctl reset-failed langsam
  • reset-failed forgets a failed state so that the name langsam is free again.

In the lab it reported:

Failed to reset failed state of unit langsam.service: Unit langsam.service not loaded.

The service had exited cleanly when stopped and was already gone – that is fine too.

Remember: Connection times of exactly 1 or 3 seconds are the fingerprint of dropped SYNs. ss -lnt shows the chairs, nstat (ListenOverflows) counts those turned away. More chairs help with peaks, more waiters with sustained load.

Save your progress? Sign up for free

Diagnosis task

After a colleague set up “just a small firewall rule for counting new connections” on perf1, the web server’s monitoring reports: throughput with short connections has collapsed. The web server itself shows no errors, the CPU is almost idle.

Setup. Four commands, one after the other:

# on perf1
sudo nft add table inet zaehler
# on perf1
sudo nft add chain inet zaehler eingang "{ type filter hook input priority 0; }"
# on perf1
sudo nft add rule inet zaehler eingang ct state new counter
# on perf1
sudo sysctl -w net.netfilter.nf_conntrack_max=2048

Please only read the meaning of the commands – especially the last one – in the solution. The load comes from last1, this time with a new connection for every request, as with many short API calls:

# on last1
wrk -t2 -c20 -d60s --timeout 5s -H "Connection: close" http://perf1/
  • -H "Connection: close" adds this header to every request: the server closes the connection after the response, and wrk has to establish a new one for the next.

Task (20 minutes): Why does the throughput drop? Find the place in the kernel that drops connections, and prove it.

Solution path

Step 1 – The symptom. wrk’s result:

  2 threads and 20 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.14ms    1.29ms   9.45ms   76.90%
    Req/Sec     2.56k     0.85k    4.11k    75.00%
  2043 requests in 1.00m, 1.67MB read
Requests/sec:     34.01
Transfer/sec:     28.46KB

34 requests per second over one minute. The latency of a successful request is unremarkable at 2 ms – the problem is the guests who do not even get in.

Step 2 – The kernel log. As always in the 60-second check. Here a simple filter makes sense, because the log is long:

# on perf1
sudo dmesg -T | grep -i conntrack
  • dmesg -T shows the kernel log with readable time, grep -i conntrack only lines with “conntrack”, regardless of upper and lower case.

Expected (excerpt – the last three lines):

[Mon Nov 30 14:37:01 2026] nf_conntrack: nf_conntrack: table full, dropping packet
[Mon Nov 30 14:37:01 2026] nf_conntrack: nf_conntrack: table full, dropping packet
[Mon Nov 30 14:37:01 2026] nf_conntrack: nf_conntrack: table full, dropping packet

The guest book is full, the kernel drops packets.

Step 3 – How full?

# on perf1
sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
  • nf_conntrack_count is the current number of entries, nf_conntrack_max the limit.

Expected:

net.netfilter.nf_conntrack_count = 1993
net.netfilter.nf_conntrack_max = 2048

1,993 of 2,048 slots taken – the limit has been reached.

Step 4 – Where is it dropped? conntrack -S shows statistics per CPU. The program conntrack came on Day 0 with the package of the same name.

# on perf1
sudo conntrack -S

Expected (one line per CPU):

cpu=0       found=0 invalid=0 insert=0 insert_failed=0 drop=0 early_drop=0 error=0 search_restart=0 clash_resolve=0 chaintoolong=0
cpu=1       found=0 invalid=0 insert=0 insert_failed=0 drop=0 early_drop=0 error=0 search_restart=0 clash_resolve=0 chaintoolong=0
cpu=2       found=0 invalid=0 insert=0 insert_failed=0 drop=334 early_drop=0 error=0 search_restart=0 clash_resolve=0 chaintoolong=0
cpu=3       found=0 invalid=0 insert=0 insert_failed=0 drop=0 early_drop=0 error=0 search_restart=0 clash_resolve=0 chaintoolong=0

334 dropped packets (drop), all on CPU 2 – the CPU that gets the network card’s receive interrupts (Drill 1).

Step 5 – Who is in the book? conntrack -L lists all entries, one line per connection:

# on perf1
sudo conntrack -L

Expected (excerpt – the first three of almost 2,000 lines):

tcp      6 53 TIME_WAIT src=172.16.0.228 dst=172.16.0.126 sport=47298 dport=80 src=172.16.0.126 dst=172.16.0.228 sport=80 dport=47298 [ASSURED] mark=0 use=1
tcp      6 53 TIME_WAIT src=172.16.0.228 dst=172.16.0.126 sport=56922 dport=80 src=172.16.0.126 dst=172.16.0.228 sport=80 dport=56922 [ASSURED] mark=0 use=1
tcp      6 53 TIME_WAIT src=172.16.0.228 dst=172.16.0.126 sport=56718 dport=80 src=172.16.0.126 dst=172.16.0.228 sport=80 dport=56718 [ASSURED] mark=0 use=1
Field Meaning
tcp 6 protocol and its number
53 seconds until the entry expires
TIME_WAIT state of the connection
src=… dst=… sport=… dport=… twice: forward and return direction
[ASSURED] traffic seen in both directions

For TCP the state is in the fourth column. In the lab 1,983 of 1,989 entries were in the state TIME_WAIT – long-closed connections that conntrack keeps for another 120 seconds. With short connections they pile up faster than they expire.

Step 6 – Where does conntrack come from at all?

# on perf1
sudo nft list table inet zaehler

Expected:

table inet zaehler {
    chain eingang {
        type filter hook input priority filter; policy accept;
        ct state new counter packets 447118 bytes 26842512
    }
}

The “small rule for counting” (table zaehler, “counter”; chain eingang, “input”) asks about the connection state (ct state new).

# on perf1
lsmod
  • lsmod lists the loaded kernel modules.

Expected (excerpt – look for the line that starts with nf_conntrack):

nf_conntrack          196608  2 nft_ct

Because of the rule, the kernel loaded the module nf_conntrack and keeps every connection in the table. Its limit was set – with the last setup command – to 2,048. The default value for this VM is 262,144: it depends on main memory.

Step 7 – Fix it. Set the limit back to the default:

# on perf1
sudo sysctl -w net.netfilter.nf_conntrack_max=262144

Step 8 – Check.

# on last1
wrk -t2 -c20 -d30s --timeout 5s -H "Connection: close" http://perf1/

Expected:

  2 threads and 20 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.63ms    1.63ms  43.16ms   83.61%
    Req/Sec     2.24k   554.64     4.15k    70.83%
  133967 requests in 30.08s, 109.49MB read
Requests/sec:   4453.26
Transfer/sec:      3.64MB

4,453 instead of 34 requests per second – 130 times as many. How large must the table be at this load? During a 70-second run, nf_conntrack_count settled at about 14,100 entries, almost all TIME_WAIT. (That is fewer than 4,450 connections per second times 120 seconds would suggest, because the load generator reuses its source ports and conntrack recycles a TIME_WAIT entry with the same tuple for the new connection.) The rule of thumb for the limit: new connections per second × lifetime of the entries, with plenty of reserve.

Step 9 – Clean up.

# on perf1
sudo nft delete table inet zaehler
# on perf1
sudo nft list ruleset

Expected: no output – no rules left. The module stays loaded until the next reboot; without rules that use it, it no longer tracks connections.

Remember: A full conntrack table only gives itself away in the kernel log (table full, dropping packet) and by nf_conntrack_count at the limit. A full guest book locks the door even though everything inside is free.

If it doesn’t work

  • sysctl: cannot stat /proc/sys/net/netfilter/nf_conntrack_max: No such file or directory: conntrack is not loaded yet. Create the nft rule first.
  • sudo: conntrack: command not found: sudo apt-get install -y conntrack.

Challenge

Instead of raising the limit, you could shorten the lifetime of the TIME_WAIT entries. Which setting is that, what would you set, and why is that riskier than a larger table?

Solution path: net.netfilter.nf_conntrack_tcp_timeout_time_wait (default 120 seconds). A shorter value makes entries expire faster; the table needs less room. It is risky because TIME_WAIT has a purpose: late packets of an old connection should not be taken for a new one with the same tuple. A larger table, on the other hand, only costs memory. How much is in /proc/slabinfo:

# on perf1
sudo grep "^nf_conntrack " /proc/slabinfo

The fourth column is the size of an entry: on perf1 256 bytes, so 64 MB in the worst case for 262,144 entries. First size the table properly; only change timeouts after careful examination.

Save your progress? Sign up for free

Checkpoint

# on perf1
sudo nft list ruleset

Expected: no output.

# on perf1
sysctl -n net.netfilter.nf_conntrack_max

Expected: 262144. If sysctl instead reports cannot stat /proc/sys/net/netfilter/nf_conntrack_max, conntrack is no longer loaded at all – that is fine too.

# on perf1
systemctl is-active langsam nginx

Expected: inactive and active – you still need nginx.

Test yourself

  1. All receive interrupts land on CPU 2. When does that become a problem, and how do you see it?
  2. A listening socket shows Recv-Q 9 and Send-Q 8. What does that mean?
  3. Clients report connection times of exactly 1 or 3 seconds. What do you think of first?
  4. Why does a larger backlog help with peaks but not with sustained load?
  5. How does conntrack get onto a server on which nobody switched “conntrack” on?
  6. How do you recognize a full conntrack table, and why are there so many TIME_WAIT entries?

Answers:

  1. When CPU 2 is full due to %soft while the other CPUs still have room – visible in mpstat -P ALL and in the NET_RX counters in /proc/softirqs. Remedy: RSS or RPS.
  2. The accept queue (8 slots) is full; new connection requests are dropped.
  3. Dropped SYNs: retry after 1 s, then after another 2 s. Check with ss -lnt, nstat (ListenOverflows) and dmesg (conntrack).
  4. The backlog only stores connections temporarily; the application has to process them. With sustained load above capacity, every buffer fills up eventually.
  5. Through any rule that asks about the state (ct state …), through NAT, Docker or Kubernetes.
  6. table full, dropping packet in dmesg, nf_conntrack_count at nf_conntrack_max. Closed TCP connections stay for 120 seconds as TIME_WAIT; many short connections fill the table this way.

Interview Note

“Clients sporadically report connection times of exactly one or three seconds.” – That is the fingerprint pattern of dropped SYNs: retry after 1 s, then 2 s. Causes: a full accept queue (ss -lnt, ListenOverflows) or a full conntrack table (dmesg, nf_conntrack_count). If you name both, you know where to look, and if you explain why a larger backlog does not replace capacity, you convince. Bonus: network work per CPU (/proc/softirqs, RSS/RPS) as a third limit.

Enterprise Note

Full conntrack tables are among the most common causes of outages on Kubernetes nodes, NAT gateways and load balancers – there conntrack is always active and the number of short connections is high. Monitor nf_conntrack_count relative to nf_conntrack_max and alert at about 75 %; the message table full in the log belongs in every alerting rule set. The same applies to the backlog for servers: monitor ListenOverflows as a rate. Both limits are cheap to raise, but only if you know that you are reaching them.

Summary

  • Interrupts and softirqs of the network card land on one CPU with one queue (/proc/interrupts, /proc/softirqs, mpstat %soft). RSS in hardware or RPS in software distributes them.
  • wrk -tN -cN -dNs creates HTTP load; nginx managed just under 30,000 requests per second and was itself the bottleneck.
  • Accept queue: ss -lnt (Recv-Q fill level, Send-Q size), nstat (ListenOverflows, ListenDrops, SyncookiesSent). An overflow costs clients 1, 3, 7 … seconds.
  • A larger backlog absorbs peaks but does not replace capacity (48 requests/s at 20 ms serially).
  • conntrack is active as soon as a rule asks about the state. Full table: table full, dropping packet in dmesg, nf_conntrack_count at the limit, many TIME_WAIT entries.
  • Diagnosis today: nf_conntrack_max = 2048 – 34 instead of 4,453 requests per second with short connections.

Commands at a glance

Command What it does Parameters
tc qdisc show dev eth0 queue of the network card –
ethtool -l eth0 queues (channels) of the network card -l channels
cat /proc/interrupts, cat /proc/softirqs interrupts and softirqs per CPU –
cat /sys/class/net/eth0/queues/rx-0/rps_cpus RPS mask 0 = off
mpstat -P ALL 2 1 CPU values per CPU %soft network work
wrk -tN -cN -dNs [--timeout 5s] [-H "Connection: close"] URL HTTP load threads, connections, duration
ss -ltn sport = :PORT listening socket with queue Recv-Q fill level, Send-Q size
nstat -n / nstat reset network counters / show since then ListenOverflows, ListenDrops
curl -w "%{time_connect} %{time_total}\n" URL connection setup and total time –
nft add table/chain/rule …, nft list …, nft delete table … firewall rules with nftables –
sysctl net.netfilter.nf_conntrack_count …_max fill level and limit of conntrack –
conntrack -S / conntrack -L conntrack statistics / entries –
dmesg -T \| grep -i conntrack messages when the table is full -T time
lsmod loaded kernel modules –

Contents

More