`
puyd123
  • 浏览: 20790 次
社区版块
存档分类
最新评论

linux tune

 
阅读更多
Linux Tuning

Table of Contents

General Approach
TCP tuning
UDP Tuning
NIC Tuning
Virtual Machine Tuning
This page contains a quick reference guide for Linux 2.6+ tuning for Data Transfer hosts connected at speeds of 1Gbps or higher. Note that most of the tuning settings described here will actually decrease performance of hosts connected at rates of OC3 (155 Mbps) or less, such as home users on Cable/DSL connections.

For a detailed explanation of some of the advice on this page, see the Linux Tuning Expert page. Note that the settings on this page are not attempting to achieve full 10G with a single flow. These settings assume you are using tools that support parallel streams, or have multiple data transfers occurring in parallel, and want to have fair sharing between the flows.

If you are trying to optimize for a single flow, see the tuning advice for test/measurement hosts page.

General Approach

To check what setting your system is using, use 'sysctl name' (e.g.: 'sysctl net.ipv4.tcp_rmem'). To change a setting use 'sysctl -w'. To make the setting permanent add the setting to the file 'sysctl.conf'.

Back to Top
TCP tuning

Like most modern OSes, Linux now does a good job of auto-tuning the TCP buffers, but the default maximum Linux TCP buffer sizes are still too small. Here are some example sysctl.conf commands for different types of hosts.

For a host with a 10G NIC, optimized for network paths up to 100ms RTT, add this to /etc/sysctl.conf

# increase TCP max buffer size settable using setsockopt()
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
# increase Linux autotuning TCP buffer limit
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# increase the length of the processor input queue
net.core.netdev_max_backlog = 30000
# recommended default congestion control is htcp
net.ipv4.tcp_congestion_control=htcp
# recommended for hosts with jumbo frames enabled
net.ipv4.tcp_mtu_probing=1
Also add this to /etc/rc.local (where N is the number for your 10G NIC):
    /sbin/ifconfig ethN txqueuelen 10000
For a host with a 10G NIC optimized for network paths up to 200ms RTT, or a 40G NIC up on paths up to 50ms RTT:

# increase TCP max buffer size settable using setsockopt()
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
# increase Linux autotuning TCP buffer limit
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
# increase the length of the processor input queue
net.core.netdev_max_backlog = 250000
# recommended default congestion control is htcp
net.ipv4.tcp_congestion_control=htcp
# recommended for hosts with jumbo frames enabled
net.ipv4.tcp_mtu_probing=1
Also add this to /etc/rc.local (where N is the number for your 10G NIC):
    /sbin/ifconfig ethN txqueuelen 10000
Notes: you should leave net.tcp_mem alone, as the defaults are fine. A number of performance experts say to also increase net.core.optmem_max to match net.core.rmem_max and net.core.wmem_max, but we have not found that makes any difference. Some experts also say to set net.ipv4.tcp_timestamps and net.ipv4.tcp_sack to 0, as doing that reduces CPU load. We strongly disagree with that recommendation, as we have observed that the default value of 1 helps in more cases than it hurts, and can help a lot.

Linux supports pluggable congestion control algorithms. To get a list of congestion control algorithms that are available in your kernel (kernal  2.6.20+), run:

sysctl net.ipv4.tcp_available_congestion_control
If cubic and/or htcp are not listed try the following, as most distributions include them as loadable kernel modules:

/sbin/modprobe tcp_htcp
/sbin/modprobe tcp_cubic
NOTE: There seem to be bugs in both bic and cubic for a number of versions of the Linux kernel up to version 2.6.33. We recommend using htcp with older kernels to be safe. To set the congestion control do:

sysctl -w net.ipv4.tcp_congestion_control=htcp
If you are using Jumbo Frames, we recommend setting tcp_mtu_probing = 1 to help avoid the problem of MTU black holes. Setting it to 2 sometimes causes performance problems.

Back to Top
UDP Tuning

The TCP window size actually effects UDP as well on Linux. Be sure to use the setsockopt() call to increase SO_SNDBUF/SO_RCVBUF to around 4MB if you want to do UDP streams that are faster than 3-4 Gbps. The optimal data payload size is the MTU size minus IP and UDP header size, or 1472 for a 1500 byte MTU and 8972 for a 9000 byte MTU.

Back to Top
NIC Tuning

This can be added to /etc/rc.local to be run at boot time:

    # increase txqueuelen for 10G NICS
    /sbin/ifconfig ethN txqueuelen 10000
Note that this might have adverse affects for a 10G host sending to a 1G host or slower.
分享到:
评论

相关推荐

    Linux application tune guide

    ### Linux应用程序调优指南知识点概览 #### 一、引言 在《Linux应用程序调优指南》这份文档中,作者们旨在帮助用户更好地理解和优化在Linux环境下的应用程序性能。随着Linux系统在服务器、工作站乃至嵌入式设备上的...

    HDTunePro专业版

    HDTunePro专业版 硬盘检测 硬盘检测专业版

    A-Tune-Collector用于各类系统资源的数据采集,也可以作为A-Tune项目的采集器

    这涵盖了Windows、Linux、Unix等常见操作系统。通过系统调用和API接口,它能够获取到操作系统的运行状态,包括但不限于: 1. **CPU利用率**:监测每个核心的负载,分析整体和单个进程的CPU使用情况。 2. **内存管理...

    Prentice.Hall.Performance.Tuning.for.Linux.Servers

    I/O, file systems, and networking Tune web, file, database, and application servers running commercial workloads Predict the impact of changes in tuning parameters or configurations Tune Linux code:...

    HDTune检测硬盘软件

    同时,它也适用于多种操作系统,如Windows和Linux等。 通过使用HDTune,用户不仅可以定期对硬盘进行维护,还可以在购买新硬盘或者更换硬盘时,进行性能对比,选择最适合自己的硬盘。在日常使用中,配合合理的数据...

    嵌入式系统/ARM技术中的Linux内核升级的基本步骤

    一、本次内核编译新内核所涉及软件版本  “gcc –version”可查寻GCC版本------4.3.2 20081105(Red Hat 4.3.2-7)  “make –v”可查询 Gnu make版本-----3.81 ... “tune2fs –version”命令可检查 tu

    Linux系统大于16T硬盘格式化工具

    在IT行业中,尤其是在服务器管理与数据中心领域,操作系统如Red Hat Enterprise Linux (RHEL)经常需要处理容量庞大的硬盘,以满足存储需求。本篇文章将详细探讨如何在Linux系统,特别是RHEL 5、6和7版本中,对大于16...

    如何恢复 Linux 被吃掉的磁盘空间.docx

    要查看或调整这个预留比例,可以使用`tune2fs`命令,例如`tune2fs -m 1 /dev/vda1`,其中1表示预留1%的磁盘空间。 通过上述步骤,你可以有效地定位并清理占用磁盘空间的文件,同时了解Linux系统为何会出现磁盘空间...

    linux-filesys.rar_linux_linux 文件系统

    以及如何调整文件系统参数以优化性能,例如使用`tune2fs`。 总的来说,理解并掌握Linux文件系统对于管理和维护Linux环境至关重要。通过学习这个压缩包提供的资料,你将能够更好地理解和操作Linux系统中的文件和目录...

    基于python开发并利用了两种深度网络 alexnet和vggnet实现了鸟类识别的finetune操作+源码+文档(高分项目

    linux+pytorch 使用规范 NetWork.py:存储模型结构 finetune_v2.py: 规范化化后的finetune版本,直接运行 k-flod-finetune.py: 使用k折交叉验证的finetune,其中修改transorm的参数就可以进行数据增强操作,直接...

    Linux Performance and Tuning Guidelines

    选择合适的文件系统,如针对大量小文件的使用ext4,大数据存储时选择XFS或Btrfs,并且定期进行文件系统检查和优化,如fsck和tune2fs,可以确保文件系统的稳定性和效率。 九、硬件兼容性和配置 硬件选择和配置对...

    linux 格式化硬盘

    ### Linux格式化硬盘详解 #### 一、概述 在Linux环境下进行硬盘格式化是一项常见的操作,主要用于准备新的存储设备或修复旧的存储设备以便再次使用。格式化涉及到选择合适的文件系统,例如FAT、NTFS、Ext等。本文...

    e2fsprogs-1.43.4 linux下载

    安装完成后,e2fsprogs提供的工具,如`mkfs.ext4`(用于创建EXT4文件系统)、`tune2fs`(用于调整文件系统参数)和`fsck.ext4`(用于检查和修复EXT4文件系统),就可以在Linux环境中使用了。这些工具对于系统管理员...

    linux 文件系统管理

    对于ext2和ext3文件系统,还可以通过`tune2fs`命令来调整其参数,如自检周期、预留块比例等。这有助于优化系统性能和数据安全,例如在系统频繁意外关机的情况下,可以调整自检周期以确保文件系统的稳定性。 综上所...

    linuxtune:Linux设置

    【标题】:“Linuxtune:Linux系统调优工具” 【描述】:“Linuxtune”是一个用于优化和调整Linux操作系统性能的工具。通过执行一系列命令,我们可以下载、解压、删除源代码包,并进入目录运行该工具。这个过程展示...

    IBM Db2 Community Edition(v11.5.6_linuxx64_server_dec.part2)

    IBM Db2 Community Edition v11.5.6 (v11.5.6_linuxx64_... 由 AI Tune 工作负载提供支持,并使用 ML 优化查询以获得更高的性能支持关键数据类型和语言noSQL、pureXML、Graph 和 JSON;Java、.Net、Ruby、Python 等。

    Advanced Raspberry Pi Raspbian Linux and GPIO Integration.zip

    Other topics covered include the 1-Wire driver interface, how to configure a serial Linux console, and cross-compile code, including the Linux kernel. You'll find yourself turning to Advanced ...

    linux教程——很使用的那种

    linux分为:redhat linux系列和debian系列。 X Window是一种协议。 unix图形环境是CDE:common desktop environment通用桌面环境。 linux系统结构:硬件、内核层、shell层、应用层、用户。 在安装linux的时候,会...

Global site tag (gtag.js) - Google Analytics