性能调优工具
tuna
Tuna 可以让你对处理器进行控制,并能很方便的进行调度。
例如:假如你拥有一个网络性能很差不过很稳定的系统,并且发现有几个核心是空闲的,就可以检查一下网卡是否已经开启了多个调度队列,以使其对性能的消耗可以分布于全部所有的核心上。
示例:被命名为“enp1s0f0” 和 “enp1s0f1”的网卡:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | [root@golem ~] # tuna --irq 'enp1s0f*' --socket 0 --spread --show_irqs
# users affinity
69 enp1s0f0 0 igb
70 enp1s0f0-rx-0 1 igb
71 enp1s0f0-rx-1 2 igb
72 enp1s0f0-rx-2 3 igb
73 enp1s0f0-rx-3 4 igb
74 enp1s0f0-tx-0 5 igb
75 enp1s0f0-tx-1 6 igb
76 enp1s0f0-tx-2 7 igb
77 enp1s0f0-tx-3 0 igb
79 enp1s0f1 1 igb
80 enp1s0f1-rx-0 2 igb
81 enp1s0f1-rx-1 3 igb
82 enp1s0f1-rx-2 4 igb
83 enp1s0f1-rx-3 5 igb
84 enp1s0f1-tx-0 6 igb
85 enp1s0f1-tx-1 7 igb
86 enp1s0f1-tx-2 0 igb
87 enp1s0f1-tx-3 1 igb
|
如果有多个网络套接入口,那么你就可以将一些处理转移到一个入口,而网络处理则转移到另外一个入口。
tuned
Tuned 可以在一些版本的 Red Hat 系统中被使用。
Tuned 带来了大量的调优配置;拥有针对各种不同的常用服务器功能用途的默认配置。有一个是针对“虚拟来宾用户”的, 还有一个是针对“虚拟主机”的, 还有“搞吞吐量” 或者 “低延迟” 的配置。它们提供了一个起点来进行更进一步探索。
例如:
1 2 3 4 5 6 7 8 9 10 11 | [root@golem ~] # tuned-adm list
- balanced
- desktop
- latency-performance
- network-latency
- network-throughput
- powersave
- throughput-performance
- virtual-guest
- virtual-host
Current active profile: throughput-performance
|
不同的默认配置都有响应的良好的文档,如果你希望的话,它们是你进行定制的一个好的起点。
其在物理机器上的默认配置为“吞吐性能” 或者 “各项均衡”, 而虚拟机上则是“虚拟来宾用户”。
tuned 的默认配置位于 /usr/lib/tuned 目录下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | [root@golem ~] # tree /usr/lib/tuned
/usr/lib/tuned
|-- balanced
| `-- tuned.conf
|-- desktop
| `-- tuned.conf
|-- functions
|-- latency-performance
| `-- tuned.conf
|-- network-latency
| `-- tuned.conf
|-- network-throughput
| `-- tuned.conf
|-- powersave
| |-- script.sh
| `-- tuned.conf
|-- recommend.conf
|-- throughput-performance
| `-- tuned.conf
|-- virtual-guest
| `-- tuned.conf
`-- virtual-host
`-- tuned.conf
|
它们都包含一个 tuned.conf 文件,带有 INI 的文件语义,还有一个可选的 shell 脚本。
要创建你自己的配置,可以复制其中一个目录到 /etc/tuned/, 做一些调整然后启用就行了。
1 2 3 | [root@golem ~] # cp -a /usr/lib/tuned/throughput-performance /etc/tuned/wonderprofile
[root@golem ~] # vim /etc/tuned/wonderprofile/tuned.conf
[root@golem ~] # tuned-adm profile wonderprofile
|
例如 /etc/tuned/wonderprofile/tuned.conf, 包含了一个配置,而且进行了调整:
1 2 3 4 5 6 | [main]
include=throughput-performance
[sysctl]
net.ipv4.tcp_rmem= "4096 87380 16777216"
net.ipv4.tcp_wmem= "4096 16384 16777216"
net.ipv4.udp_mem= "3145728 4194304 16777216"
|
示例 /etc/tuned/wonderprofile/script.sh:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/bin/sh
# Lots of functions in here to use
. /usr/lib/tuned/functions
start() {
[ "$USB_AUTOSUSPEND" = 1 ] && enable_usb_autosuspend
enable_wifi_powersave
return 0
}
stop() {
[ "$USB_AUTOSUSPEND" = 1 ] && disable_usb_autosuspend
disable_wifi_powersave
return 0
}
process $@
|