高 CPU - mysqltuner 帮助(wordpress)

高 CPU - mysqltuner 帮助(wordpress)

我刚刚将 wordpress 博客迁移到新服务器。它有大约 120K 个帖子。

问题是它在 mysql 操作期间会卡住、挂起甚至冻结。单个 wordpress(没有任何插件)创建帖子操作会消耗 60-80% 的 CPU。执行 3-5 个数据库操作时它会冻结。并且没有任何慢查询日志。

系统:Ubuntu 18.04,16GB RAM,8 核 CPU,120GB 磁盘和 MySQL 版本 5.7.25

以下是 mysqltuner 和其他报告

和当前的 mysql.cnf

[mysqld]
# Skip reverse DNS lookup of clients
skip-name-resolve
default-storage-engine=InnoDB

max_allowed_packet=500M
max_connections = 256
interactive_timeout=7200
wait_timeout=7200

innodb_file_per_table=1
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 4
innodb_log_file_size = 1G
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
innodb_open_files=5000
innodb_io_capacity=2000
innodb_io_capacity_max=4000
innodb_old_blocks_time=2000
open_files_limit=50000

query_cache_type = 1
query_cache_min_res_unit = 1M
query_cache_limit = 1M
query_cache_size = 50M

tmp_table_size= 256M
max_heap_table_size= 256M

#key_buffer_size = 128M
thread_stack = 128K
thread_cache_size = 32

slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
long_query_time = 1

编辑: 我上面粘贴的初始 mysql.cnf 变量与生成 mysqltuner 报告时的值相比,有一些不正确/更改的值。已更正,谢谢@EchoMike444

答案1

每秒速率 = RPS - 建议考虑您的 my.cnf [mysqld] 部分,

innodb_lru_scan_depth=100  # from 1024 to reduce 90% of cpu cycles used for function every SECOND
innodb_io_capacity=3500  # from 2000 to enable higher IOPS on your SSD devices
innodb_flushing_avg_loops=5  # from 30 to reduce innodb_buffer_pool_pages_dirty overhead - count was 3183 in SGStatus
read_buffer_size=256K  # from 128K to reduce handler_read_next RPS of 277,134
read_rnd_buffer_size=192K  # from 256K to reduce handler_read_rnd_next RPS of 778

通过全局变量还有更多机会提高性能。免责声明:我是个人资料中提到的网站的作者,网络资料中包含联系信息。

答案2

WordPress 中的“元”表具有低效的模式。 讨论使它们更高效所需的修复。

这些修复无法解决 WordPress 固有的 EAV(实体-属性-值)模式的固有低效率问题。

相关内容