Linux通过Tuned实现动态调优系统性能

2023-10-17 22:40

本文主要是介绍Linux通过Tuned实现动态调优系统性能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Linux通过Tuned实现动态调优系统性能

Tuned简介

对于普通用户来说,优化Linux应用环境可能是相当具有挑战性的。它涵盖了各种领域,并且有许多参数需要考虑,比如CPU、存储、缓存策略和内存管理。尽管Linux有默认设置可以处理大多数情况和场景,但是对于高性能、高并发和高可用性系统等特殊场景,需要进行调整。本文讨论的特性是tuned,它是Linux系统中常用的一种调优服务。

tuned由两个程序组成:tuned和tuned-adm。tuned是服务端程序,用于监控和收集系统各个组件的数据;而tuned-adm是客户端程序,通过命令行管理和配置tuned。

tuned提供了几种预先配置的优化策略(配置文件),可以直接使用,例如balanced、desktop、throughput-performance、latency-performance、powersave及其他优化场景。然而,不同的系统和应用场景可能需要不同的优化方法,tuned预先配置的配置文件可能并不总能满足要求。因此,tuned还允许用户创建和自定义自己的调优配置文件。

Tuned的子系统

tuned子系统是独立运行的,它们共同组成了tuned的调优方案。每个子系统可以支持多个设备(每个设备可能包含多个CPU、网卡等设备),并且每个设备可以使用独立的实例进行控制。

Tuned调优性能

在实际环境中,系统资源可能不足以支持正在运行的进程。管理员可以根据不同的用例和工作负载来调整系统资源的分配,以实现系统优化。

Tuned服务

tuned是一个服务端程序,包含并启用于RHEL8/RHEL7/CentOS7的最小安装中。其守护进程tuned可以根据调优配置文件以静态和动态两种模式应用调优调整。

tuned is a server-side program that is included and enabled in the minimal installation of RHEL8. Its daemon process, tuned, can apply tuning adjustments based on tuning configuration files in both static and dynamic modes.

调优方式:
  • 静态调整:内核参数针对整体性能预期而设置的,不会随实际负载变化而调整,但配 置简单
  • 动态调整:tuned 守护进程会监控和收集系统各个组件的数据,并依据数据提供的信 息动态调整系统设置,达到动态优化系统的目的


安装并启用 TUNED

yum install -y tuned   # 安装软件包
systemctl start tuned  # 启动tuned服务
systemctl stop tuned   # 停止tuned服务
systemctl enable --now tuned   # 设置开机自启动
systemctl enable tuned  # 自启动/禁止自启动tuned-adm profile throughput-performance # 开启高性能
tuned-adm active # 显示当前性能模式
tuned-adm off # 关闭tuned服务的相关配置目录:
/usr/lib/tuned/         # 原生的性能模式/etc/tuned              # DIY的性能模式
├── active_profile      # 当前的性能模式
├── bootcmdline         
└── tuned-main.conf

TUNED 提供的profiles配置文件

tuned提供的profiles,tuned会预先配置的一些优化策略,下面依次介绍下

 配置类型说明

  • balanced    适合需要在节能和性能之间进行折衷的系统
  • desktop    从 balanced 配置文件衍生而来,加快交互式应用相应速度
  • throughput-performance    调优系统以获得最大的吞吐量
  • latency-performance    适合需要牺牲能耗来获取低延迟的服务器系统
  • network-latency    从 latency-performance 配置文件衍生而来,获得最低网络延迟
  • network-throughput    从 throughput-performance 配置文件衍生而来,获得最低网络延迟
  • powersave    调优系统以最大程度实现节能
  • oracle    基于 throughput-performance 配置文件,针对 Oracle 负载优化
  • virtual-guest    当系统在虚拟机上运行时,调优系统以获得最高性能
  • virtual-host    当系统充当虚拟机的主机时,调优系统以获得最高性能


从命令行管理配置文件

  • tuned-adm active 查看启用的调优配置
  • tuned-adm list 查看所有可用的调优配置文件
  • tuned-adm profile 启用某个调优配置文件
  • tuned-adm recommend 查看系统推荐的调优文件
  • tuned-adm off 关闭 tuned 系统调优

tuned使用说明

CentOS7默认安装并启动了tuned服务,如果没有的话可以手动安装和启动:

# yum install tuned     -- 安装tuned
# service tuned start    -- 启动tuned服务
# service tuned status   -- 查看tuned状态

对tuned的操作主要通过tuned-adm命令实现。

查看所有可用的profiles和当前使用的profile:

# tuned-adm list
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optimize for the desktop use-case
- hpc-compute                 - Optimize for HPC compute workloads
- latency-performance         - Optimize for deterministic performance at the cost of increased power consumption
- network-latency             - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput          - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- powersave                   - Optimize for low power consumption
- throughput-performance      - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest               - Optimize for running inside a virtual guest
- virtual-host                - Optimize for running KVM guests
Current active profile: throughput-performance

只查看当前使用的profile:

[root@~]#  tuned-adm active
Current active profile: throughput-performance

切换profile:

[root@~]#  tuned-adm profile balanced
[root@~]#  tuned-adm active
Current active profile: balanced

关闭tuned的优化策略:                                                                                                                        

[root@~]#  tuned-adm off
[root@~]# 

关闭tuned之后可以使用“tuned-adm profile”命令重新打开优化策略: 

[root@~]# tuned-adm off
[root@~]# tuned-adm recommend
balanced
[root@~]# tuned-adm profile throughput-performance 
[root@~]# tuned-adm active 
Current active profile: throughput-performance
[root@~]# 

查看系统推荐的profile:

[root@~]#  tuned-adm recommend
balanced

在cockpit控制台系统页面设置性能配置集

通过cpupowerutils开启CPU高性能

# 安装cpupowerutils
yum -y install cpupowerutils
# 开启高性能
cpupower frequency-set -g performance
# 查看
cpupower frequency-info
cat /proc/cpuinfo | grep MHz
# 模式说明:
performance 运行于最大频率
powersave 运行于最小频率
userspace 运行于用户指定的频率
ondemand 按需快速动态调整CPU频率, 一有cpu计算量的任务,就会立即达到最大频率运行,空闲时间增加就降低频率
conservative 按需快速动态调整CPU频率, 比 ondemand 的调整更保守
schedutil 基于调度程序调整 CPU 频率

通过cpupower查看当前CPU频率策略:

设置CPU governor的值为配置文件中 “governor” 参数的值;CPU governor是内核的CPU频率管理器,通过参数来对CPU的频率进行调节,主要是以下几种参数:

 CPU 的governor可以使用如下命令查看:

查看目前支持的governor

[root@~]# cpupower --cpu all frequency-info --governors
analyzing CPU 0:available cpufreq governors: performance powersave

查看正在使用的governor

[root@~]# cpupower --cpu all frequency-info --policy
analyzing CPU 0:current policy: frequency should be within 800 MHz and 4.10 GHz.The governor "performance" may decide which speed to usewithin this range.

Tuned调优总结

tuned特性主要利用Linux系统中已有的调优方法和工具,包括对电源管理、CPU、内存和磁盘等内核参数的调整。这些方法和工具被整合到具体的profile配置文件中,以便于对系统进行性能调优。

对于Linux操作系统的用户来说,根据不同的使用场景和需求调整系统性能非常方便。他们可以轻松地使用现有的配置文件或自定义自己的配置文件,极大地简化了操作系统性能调优的过程。

The tuned feature primarily utilizes existing tuning methods and tools available in the Linux system, including power management utilities and adjustments to kernel parameters such as CPU, memory, and disk. These are integrated into specific profiles to facilitate performance tuning of the system.

For users of the Linux operating system, it is convenient to adjust the system's performance based on different usage scenarios and requirements. They can easily utilize existing profiles or customize their own profiles, greatly simplifying the process of performance tuning for the operating system.


原文链接:调优系统性能

原文链接:详解Linux性能调优之tuned特性 | Lenix Blog

这篇关于Linux通过Tuned实现动态调优系统性能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/228404

相关文章

MySQL 多列 IN 查询之语法、性能与实战技巧(最新整理)

《MySQL多列IN查询之语法、性能与实战技巧(最新整理)》本文详解MySQL多列IN查询,对比传统OR写法,强调其简洁高效,适合批量匹配复合键,通过联合索引、分批次优化提升性能,兼容多种数据库... 目录一、基础语法:多列 IN 的两种写法1. 直接值列表2. 子查询二、对比传统 OR 的写法三、性能分析

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

Linux下删除乱码文件和目录的实现方式

《Linux下删除乱码文件和目录的实现方式》:本文主要介绍Linux下删除乱码文件和目录的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux下删除乱码文件和目录方法1方法2总结Linux下删除乱码文件和目录方法1使用ls -i命令找到文件或目录

SpringBoot+EasyExcel实现自定义复杂样式导入导出

《SpringBoot+EasyExcel实现自定义复杂样式导入导出》这篇文章主要为大家详细介绍了SpringBoot如何结果EasyExcel实现自定义复杂样式导入导出功能,文中的示例代码讲解详细,... 目录安装处理自定义导出复杂场景1、列不固定,动态列2、动态下拉3、自定义锁定行/列,添加密码4、合并

mybatis执行insert返回id实现详解

《mybatis执行insert返回id实现详解》MyBatis插入操作默认返回受影响行数,需通过useGeneratedKeys+keyProperty或selectKey获取主键ID,确保主键为自... 目录 两种方式获取自增 ID:1. ​​useGeneratedKeys+keyProperty(推

Spring Boot集成Druid实现数据源管理与监控的详细步骤

《SpringBoot集成Druid实现数据源管理与监控的详细步骤》本文介绍如何在SpringBoot项目中集成Druid数据库连接池,包括环境搭建、Maven依赖配置、SpringBoot配置文件... 目录1. 引言1.1 环境准备1.2 Druid介绍2. 配置Druid连接池3. 查看Druid监控

Linux在线解压jar包的实现方式

《Linux在线解压jar包的实现方式》:本文主要介绍Linux在线解压jar包的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux在线解压jar包解压 jar包的步骤总结Linux在线解压jar包在 Centos 中解压 jar 包可以使用 u

linux解压缩 xxx.jar文件进行内部操作过程

《linux解压缩xxx.jar文件进行内部操作过程》:本文主要介绍linux解压缩xxx.jar文件进行内部操作,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、解压文件二、压缩文件总结一、解压文件1、把 xxx.jar 文件放在服务器上,并进入当前目录#

Linux系统性能检测命令详解

《Linux系统性能检测命令详解》本文介绍了Linux系统常用的监控命令(如top、vmstat、iostat、htop等)及其参数功能,涵盖进程状态、内存使用、磁盘I/O、系统负载等多维度资源监控,... 目录toppsuptimevmstatIOStatiotopslabtophtopdstatnmon

c++ 类成员变量默认初始值的实现

《c++类成员变量默认初始值的实现》本文主要介绍了c++类成员变量默认初始值,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录C++类成员变量初始化c++类的变量的初始化在C++中,如果使用类成员变量时未给定其初始值,那么它将被