MySQL,PHP-CPU重载

时间:2018-08-03 08:09:36

标签: php mysql wordpress ubuntu

我无法指出问题所在,我正在寻求帮助。 我在Vultr上使用VPS,2个vCore,4GB RAM在Ubuntu 16.04(nginx,php-fpm,http / 2和当前已停用的Redis)上运行Wordpress网站。 Wordpress将数据存储在后元表中,在我们的情况下,该表相当大。

我正在观察排名最高/排名最高的流程列表,这就是发生的情况。

当我单击任何页面时,它的加载速度非常快。当我单击第一个页面后的另一个页面时,最多可能需要12秒(!)进行sql查询,生成一个页面并将其加载到用户。

因此,当我观察顶部/顶部的处理列表时,会发生什么情况。

当用户打开第一页(无论哪个页面)时,它几乎立即加载,在接下来的10秒钟左右的时间内,CPU会跳到100%并保持在100%,并有一些振荡。在此期间,如果用户单击任何下一页链接,则他或她必须等待那10秒钟的高CPU使用率才能显示下一页。 如果用户等待这个较高的CPU峰值下降,则几乎立即加载下一页,然后CPU达到峰值,等等。

使CPU达到峰值的过程是mysqld和php-fpm。

这是mysql调谐器转储:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  211k  100  211k    0     0   296k      0 --:--:-- --:--:-- --:--:-- 8295k
 >>  MySQLTuner 1.7.9 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials from Debian maintenance account.
[OK] Currently running supported MySQL version 5.7.21-0ubuntu0.16.04.1
[OK] Operating on 64-bit architecture

-------- Log file Recommendations 
[--] Log file: ktc.com.err(0B)
[OK] Log file ktc.com.err exists
[OK] Log file ktc.com.err is readable.
**[!!] Log file ktc.com.err is empty**
[OK] Log file ktc.com.err is smaller than 32 Mb
[OK] ktc.com.err doesn't contain any warning.
[OK] ktc.com.err doesn't contain any error.
[--] 0 start(s) detected in ktc.com.err
[--] 0 shutdown(s) detected in ktc.com.err

-------- Storage Engine Statistics 
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in InnoDB tables: 557.5M (Tables: 109)
[OK] Total fragmented tables: 0

-------- Security Recommendations 
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'admin_default@%' does not specify hostname restrictions.
[!!] User 'admin_gme@%' does not specify hostname restrictions.
[!!] There is no basic password file list!

-------- CVE Security Recommendations 
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics 
[--] Up for: 27m 26s (33K q [20.584 qps], 259 conn, TX: 988M, RX: 6M)
[--] Reads / Writes: 96% / 4%
[--] Binary logging is disabled
[--] Physical Memory     : 3.9G
[--] Max MySQL memory    : 338.9M
[--] Other process memory: 249.1M
[--] Total buffers: 169.0M global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 72B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 173.5M (4.39% of installed RAM)
[OK] Maximum possible memory usage: 338.9M (8.58% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/33K)
[OK] Highest usage of available connections: 2% (4/151)
[OK] Aborted connections: 0.39%  (1/259)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 30K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (21 temp sorts / 7K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 72% (2K on disk / 3K total)
[OK] Thread cache hit rate: 98% (4 created / 259 connections)
[OK] Table cache hit rate: 20% (406 open / 2K opened)
[OK] Open file limit used: 1% (13/1K)
[OK] Table locks acquired immediately: 100% (171 immediate / 171 locks)

-------- Performance schema 
[--] Memory used by P_S: 72B
[--] Sys schema is installed.

-------- ThreadPool Metrics 
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics 
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/43.0K
[!!] Read Key buffer hit rate: 83.3% (126 cached / 21 reads)

-------- InnoDB Metrics 
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 128.0M/557.5M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 99.47% (50550184 hits/ 50819499 total)
[!!] InnoDB Write Log efficiency: 77.35% (5215 hits/ 6742 total) 
[OK] InnoDB log waits: 0.00% (0 waits / 1527 writes)

-------- AriaDB Metrics 
[--] AriaDB is disabled.

-------- TokuDB Metrics 
[--] TokuDB is disabled.

-------- XtraDB Metrics 
[--] XtraDB is disabled.

-------- RocksDB Metrics 
[--] RocksDB is disabled.

-------- Spider Metrics 
[--] Spider is disabled.

-------- Connect Metrics 
[--] Connect is disabled.

-------- Galera Metrics 
[--] Galera is disabled.

-------- Replication Metrics 
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations 
General recommendations:
    Restrict Host for user@% to user@SpecificDNSorIp
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: (link shortener deleted)
    Variables to adjust:
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    innodb_buffer_pool_size (>= 557.5M) if possible.
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

0 个答案:

没有答案