Skip to content

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.

License

Notifications You must be signed in to change notification settings

SergiyBabenkov/linux-network-buffer-tuning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Network Buffer Tuning Guide

License: MIT Platform Shell

Overview

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.

Key Features

  • 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

Repository Structure

Core Concepts

  1. Data Journey Through the Stack
    Traces how a write() call transforms into electrical signals on the wire. Covers user space buffers, kernel TCP/IP stack, driver queues, and NIC transmission.

  2. Hardware and Link Layer Boundaries
    Explains MTU, MSS, and how frame size impacts latency. Understanding where software ends and hardware begins.

  3. Socket Buffer Architecture
    Deep dive into SO_SNDBUF, SO_RCVBUF, TCP window scaling, and how kernel manages memory for a connections.

  4. 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.

  5. Queueing and Congestion Control
    Understanding where packets wait, why queues exist, and how TCP congestion control algorithms affect a latency profile.

Diagnostics and Optimization

  1. Detecting Memory Pressure and Loss
    Tools and techniques to identify when buffers overflow, packets drop, or system memory becomes constrained. Reading /proc statistics and netstat output.

  2. RTT-Based Buffer Sizing
    Calculating optimal buffer sizes based on actual Round Trip Time measurements and Bandwidth-Delay Product principles.

  3. 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.

Implementation

  1. Diagnostics and Troubleshooting Common configuration inconsistency patterns, detection methods, and troubleshooting procedures for network buffer issues.

  2. Monitoring and Maintenance
    Setting up ongoing instrumentation to track network health, detect degradation, and maintain optimal performance.

  3. Practical Shell Scripts and Recipes
    Production-ready bash scripts for system auditing, buffer calculation, network monitoring, and automated validation procedures.

Quick Start

For readers who want to jump straight to implementation:

  1. Read Data Journey Through the Stack to build a mental model
  2. Review Socket Buffer Architecture to understand what you're tuning
  3. Review RTT-Based Buffer Sizing to understand buffer sizing methodology for your traffic profile
  4. Jump to System Tuning Profiles for concrete tuning parameters
  5. Run the system audit script from Shell Scripts and Recipes to baseline your current configuration
  6. Follow Diagnostics and Troubleshooting to identify and fix any issues

Learning Approach

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

Releases

No releases published

Packages

No packages published