Practical eBPF Socket Tracing Without Kernel Module Headaches

· Daniel Lin ebpflinuxnetworkingobservability

Whenever a microservices team reports intermittent RPC timeouts, the network gets blamed first and proven guilty last. Full packet captures with tcpdump quickly become unusable on 10 Gbps links. Modern CO-RE (Compile Once – Run Everywhere) eBPF programs let us attach lightweight kernel tracepoints in seconds with negligible overhead.

Measuring Retransmits Per Process and Destination

Instead of dumping payloads, attaching a 40-line bpftrace one-liner to tracepoint:tcp:tcp_retransmit_skb gives an immediate histogram of which peer subnets and local PIDs are dropping frames:

bpftrace -e '
tracepoint:tcp:tcp_retransmit_skb {
  @retrans[comm, ntop(args->daddr)] = count();
}
interval:s:10 {
  print(@retrans);
  clear(@retrans);
}'

What We Found

Within five minutes we saw retransmissions clustered strictly around a single NAT gateway instance whose conntrack table was hitting nf_conntrack_max during peak bursts. Because packets were silently dropped inside conntrack before reaching the destination host, application logs only saw generic context deadline exceeded errors.

Raising net.netfilter.nf_conntrack_max and switching short-lived internal health checks to persistent connections reduced cross-AZ retransmits by 96%.

← Zero-Downtime TLS Certificate Rotation Patterns for Edge ProxiesWhy We Replaced Complex Service Meshes with Boring L4 Load Balancers →