MySQL Eating So Much CPU

Ajie

Member
Dear Mailwizz Community,

Since I'm using PCNTL for delivery seems like MySQL server sometimes gone away and the app loading slow.

Here's some example of what I get in application log:
Code:
2018/01/23 00:54:16 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. The SQL statement executed was: INSERT INTO `mw_delivery_server_usage_log` (`delivery_for`, `customer_countable`, `server_id`, `customer_id`, `date_added`) VALUES (:yp0, :yp1, :yp2, :yp3, NOW()).
2018/01/23 00:54:16 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. The SQL statement executed was: INSERT INTO `mw_campaign_delivery_log` (`processed`, `retries`, `max_retries`, `delivery_confirmed`, `status`, `campaign_id`, `subscriber_id`, `email_message_id`, `message`, `server_id`, `date_added`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, NOW()).
2018/01/23 00:54:16 [error] [application] CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
2018/01/23 00:54:16 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. The SQL statement executed was: INSERT INTO `mw_delivery_server_usage_log` (`delivery_for`, `customer_countable`, `server_id`, `customer_id`, `date_added`) VALUES (:yp0, :yp1, :yp2, :yp3, NOW()).
2018/01/23 00:54:16 [error] [system.db.CDbCommand] CDbCommand::execute() failed: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. The SQL statement executed was: INSERT INTO `mw_campaign_delivery_log` (`processed`, `retries`, `max_retries`, `delivery_confirmed`, `status`, `campaign_id`, `subscriber_id`, `email_message_id`, `message`, `server_id`, `date_added`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, NOW()).
2018/01/23 00:54:16 [error] [application] CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

I'm using Six cores CPU with 24GB RAM, VestaCP as control panel
Here's my load at the moment:
Code:
top - 07:58:41 up 59 days,  6:36,  2 users,  load average: 0.44, 0.32, 0.28
Tasks: 294 total,   4 running, 290 sleeping,   0 stopped,   0 zombie
Cpu(s): 67.3%us, 11.4%sy,  0.0%ni, 16.2%id,  0.2%wa,  0.0%hi,  0.3%si,  4.6%st
Mem:  24607648k total,  2209640k used, 22398008k free,   140816k buffers
Swap:  1048572k total,        0k used,  1048572k free,   538656k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
31076 mysql     20   0 3488m 135m 5172 S 428.1  0.6   2063:24 mysqld

And this is my.cnf settings:
Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 32M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8

#innodb_use_native_aio = 0
innodb_file_per_table

max_connections=200
max_user_connections=1000
wait_timeout=10
interactive_timeout=50
long_query_time=5

#slow_query_log=1
#slow_query_log_file=/var/log/mysql-slow-queries.log


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

I'm using 20 external SMTP delivery servers which should be running at the same time.

Can someone please suggest me how to optimize this much further?
 
Last edited:
@twisted1919 Thanks, that helps me a lot.

So I made a fresh install of CentOS 7 64bit with VestaCP, applied all of suggestions wrote there (except Nginx, because I actually don't have idea how to use Nginx) and now running smoothly!

Cheers!
 
Back
Top