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

相关文章

SpringBoot实现文件记录日志及日志文件自动归档和压缩

《SpringBoot实现文件记录日志及日志文件自动归档和压缩》Logback是Java日志框架,通过Logger收集日志并经Appender输出至控制台、文件等,SpringBoot配置logbac... 目录1、什么是Logback2、SpringBoot实现文件记录日志,日志文件自动归档和压缩2.1、

Python实现pdf电子发票信息提取到excel表格

《Python实现pdf电子发票信息提取到excel表格》这篇文章主要为大家详细介绍了如何使用Python实现pdf电子发票信息提取并保存到excel表格,文中的示例代码讲解详细,感兴趣的小伙伴可以跟... 目录应用场景详细代码步骤总结优化应用场景电子发票信息提取系统主要应用于以下场景:企业财务部门:需

基于Python实现智能天气提醒助手

《基于Python实现智能天气提醒助手》这篇文章主要来和大家分享一个实用的Python天气提醒助手开发方案,这个工具可以方便地集成到青龙面板或其他调度框架中使用,有需要的小伙伴可以参考一下... 目录项目概述核心功能技术实现1. 天气API集成2. AI建议生成3. 消息推送环境配置使用方法完整代码项目特点

spring-gateway filters添加自定义过滤器实现流程分析(可插拔)

《spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔)》:本文主要介绍spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔),本文通过实例图... 目录需求背景需求拆解设计流程及作用域逻辑处理代码逻辑需求背景公司要求,通过公司网络代理访问的请求需要做请

使用Python获取JS加载的数据的多种实现方法

《使用Python获取JS加载的数据的多种实现方法》在当今的互联网时代,网页数据的动态加载已经成为一种常见的技术手段,许多现代网站通过JavaScript(JS)动态加载内容,这使得传统的静态网页爬取... 目录引言一、动态 网页与js加载数据的原理二、python爬取JS加载数据的方法(一)分析网络请求1

Spring Security介绍及配置实现代码

《SpringSecurity介绍及配置实现代码》SpringSecurity是一个功能强大的Java安全框架,它提供了全面的安全认证(Authentication)和授权(Authorizatio... 目录简介Spring Security配置配置实现代码简介Spring Security是一个功能强

SpringCloud使用Nacos 配置中心实现配置自动刷新功能使用

《SpringCloud使用Nacos配置中心实现配置自动刷新功能使用》SpringCloud项目中使用Nacos作为配置中心可以方便开发及运维人员随时查看配置信息,及配置共享,并且Nacos支持配... 目录前言一、Nacos中集中配置方式?二、使用步骤1.使用$Value 注解2.使用@Configur

Python+PyQt5实现MySQL数据库备份神器

《Python+PyQt5实现MySQL数据库备份神器》在数据库管理工作中,定期备份是确保数据安全的重要措施,本文将介绍如何使用Python+PyQt5开发一个高颜值,多功能的MySQL数据库备份工具... 目录概述功能特性核心功能矩阵特色功能界面展示主界面设计动态效果演示使用教程环境准备操作流程代码深度解

golang float和科学计数法转字符串的实现方式

《golangfloat和科学计数法转字符串的实现方式》:本文主要介绍golangfloat和科学计数法转字符串的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望... 目录golang float和科学计数法转字符串需要对float转字符串做处理总结golang float

linux lvm快照的正确mount挂载实现方式

《linuxlvm快照的正确mount挂载实现方式》:本文主要介绍linuxlvm快照的正确mount挂载实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux lvm快照的正确mount挂载1. 检查快照是否正确创建www.chinasem.cn2.