Comprehensive guide for tuning Linux network stack buffers (socket, TCP, qdisc, NIC rings) on RHEL/OEL 8. Includes detailed documentation, RTT-based buffer calculations, tuning profiles for low-latency and high-throughput scenarios, and production-ready shell scripts for validation and monitoring.
This repository provides deep technical documentation for optimizing the complete data path from application socket buffers through kernel networking layers to the physical wire.
- Complete Stack Coverage: Socket buffers → TCP layer → Queueing disciplines → NIC ring buffers → Wire
- RTT-Based Calculations: Scientific approach to buffer sizing using Bandwidth-Delay Product
- Multiple Tuning Profiles: Pre-configured settings for message delivery, file transfer, backend, and Internet-facing scenarios
- Production-Ready Scripts: Automated audit, consistency checking, and fix application with backup
- Deep Diagnostics: Tools and techniques to identify packet drops, buffer overflows, and memory pressure
- Platform-Specific: Tested and optimized for RHEL/OEL 8 environments
Target Environment: RedHat Enterprise Linux 8 / Oracle Enterprise Linux 8
Primary Use Cases:
- Message Delivery Systems: Low-latency delivery of small messages (1-5KB) with minimal data loss during network disruptions
- File Transfer Systems: High-throughput transfer of large files (MB to GB) with efficient buffer utilization
Deployment Scenarios:
- Backend (Datacenter): Systems within same availability zone or datacenter (RTT 0.5-5ms)
- Customer-facing (Internet): Services accepting traffic over the Internet globally (RTT 50-200ms)
- Cross-region: Communication between datacenters or regions (RTT 10-100ms)
Focus: Optimizing buffer sizing and tuning parameters for specific traffic patterns, minimizing queuing delays and packet loss at every network layer
-
Data Journey Through the Stack
Traces how awrite()call transforms into electrical signals on the wire. Covers user space buffers, kernel TCP/IP stack, driver queues, and NIC transmission. -
Hardware and Link Layer Boundaries
Explains MTU, MSS, and how frame size impacts latency. Understanding where software ends and hardware begins. -
Socket Buffer Architecture
Deep dive intoSO_SNDBUF,SO_RCVBUF, TCP window scaling, and how kernel manages memory for a connections. -
System Memory and Kernel Accounting
How Linux tracks network memory usage, the relationship between socket buffers and system memory limits, and when the kernel applies backpressure. -
Queueing and Congestion Control
Understanding where packets wait, why queues exist, and how TCP congestion control algorithms affect a latency profile.
-
Detecting Memory Pressure and Loss
Tools and techniques to identify when buffers overflow, packets drop, or system memory becomes constrained. Reading/procstatistics and netstat output. -
RTT-Based Buffer Sizing
Calculating optimal buffer sizes based on actual Round Trip Time measurements and Bandwidth-Delay Product principles. -
System Tuning Profiles Complete system tuning checklists for RHEL/OEL 8 tailored to message delivery and file transfer use cases, including kernel parameters, interrupt handling, and CPU affinity for network processing.
-
Diagnostics and Troubleshooting Common configuration inconsistency patterns, detection methods, and troubleshooting procedures for network buffer issues.
-
Monitoring and Maintenance
Setting up ongoing instrumentation to track network health, detect degradation, and maintain optimal performance. -
Practical Shell Scripts and Recipes
Production-ready bash scripts for system auditing, buffer calculation, network monitoring, and automated validation procedures.
For readers who want to jump straight to implementation:
- Read Data Journey Through the Stack to build a mental model
- Review Socket Buffer Architecture to understand what you're tuning
- Review RTT-Based Buffer Sizing to understand buffer sizing methodology for your traffic profile
- Jump to System Tuning Profiles for concrete tuning parameters
- Run the system audit script from Shell Scripts and Recipes to baseline your current configuration
- Follow Diagnostics and Troubleshooting to identify and fix any issues
Each section builds on previous concepts, but readers can jump directly to topics of interest. Cross-references link related concepts throughout the documentation.
Start here: Data Journey Through the Stack