apache, php-fpm 100% cpu

Several times a day I see 100% CPU utilization and all processes using php-fpm. Apache logs doesn’t give me any information, because I don’t have many requests from the same adresses IP.

On server I have only one page wordpress with woocommerce which visiting about 2-3 thousand users per day, sometime in peak about 100-200 users. What I did:

  • I enabled redis, wp-fastest cache which cache page to static html
  • I changed changed default value from pm.max_children = 10 to pm.max_children = 5
  • I create swap file 4GB
  • I disabled wp-cron, xlmrpc.php
  • I enabled opcache
  • I used MySQLTuner-perl to opitimze database and I set
[mysqld]
Settings buforrer InnoDB
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_log_buffer_size = 256M

table_definition_cache = 600
query_cache_size = 0
local-infile = 0
max_allowed_packet=64M

slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 5

My server configuration.

  • CPU Intel(R) Xeon(R) Gold 6150 CPU @ 4 X 2.70GHz
  • Memory 8 GB (Cached:3.71 GB/ Used: 3.71 GB, Free: 1.16 GB)
  • Disk 500GB Nvme