Linode Alert - CPU Usage
top shows the following:
top - 13:58:47 up 58 days, 23:32, 1 user, load average: 0.53, 0.54, 0.58
Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie
Cpu(s): 26.6%us, 3.7%sy, 0.0%ni, 69.1%id, 0.0%wa, 0.0%hi, 0.1%si, 0.6%st
Mem: 509424k total, 367564k used, 141860k free, 104668k buffers
Swap: 524284k total, 16244k used, 508040k free, 118332k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2206 mysql 20 0 127m 26m 3108 S 124 5.3 29427:09 mysqld
14798 www-data 20 0 60600 25m 3776 S 66 5.1 0:07.11 apache2
14806 www-data 20 0 46044 11m 3760 S 1 2.3 0:03.38 apache2
1 root 20 0 2084 512 508 S 0 0.1 0:56.11 init
2 root 20 0 0 0 0 S 0 0.0 0:00.12 kthreadd
3 root 20 0 0 0 0 S 0 0.0 0:05.87 ksoftirqd/0
4 root 20 0 0 0 0 S 0 0.0 1:44.20 kworker/0:0
5 root 20 0 0 0 0 S 0 0.0 0:00.03 kworker/u:0
6 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/0
7 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/1
8 root 20 0 0 0 0 S 0 0.0 0:00.00 kworker/1:0
9 root 20 0 0 0 0 S 0 0.0 0:06.41 ksoftirqd/1
10 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/2
11 root 20 0 0 0 0 S 0 0.0 0:00.00 kworker/2:0
12 root 20 0 0 0 0 S 0 0.0 0:05.73 ksoftirqd/2
13 root RT 0 0 0 0 S 0 0.0 0:00.00 migration/3
14 root 20 0 0 0 0 S 0 0.0 0:00.00 kworker/3:0
and vmstat shows:
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 16244 165524 104736 118348 0 0 1 0 1 0 5 1 94 0
1 0 16244 165392 104736 118368 0 0 0 36 263 172 1 0 99 0
1 0 16244 163656 104744 118364 0 0 0 16 10650 11749 14 1 84 0
1 0 16244 163656 104744 118368 0 0 0 0 1026 21 14 0 86 0
1 0 16244 163656 104744 118368 0 0 0 0 1042 23 15 0 85 0
0 0 16244 165020 104752 118360 0 0 0 16 592 76 7 0 93 0
0 0 16244 165044 104752 118360 0 0 0 48 57 33 0 0 100 0
0 0 16244 165044 104752 118368 0 0 0 0 33 25 0 0 100 0
0 0 16244 164920 104760 118360 0 0 0 52 46 36 0 0 100 0
3 0 16244 156728 104760 118368 0 0 0 0 5327 5444 4 1 95 0
2 0 16244 153224 104760 118368 0 0 0 4 41555 48252 33 8 58 0
2 0 16244 151488 104760 118368 0 0 0 4 23612 26501 30 3 66 0
2 0 16244 149876 104760 118368 0 0 0 0 24497 27539 49 6 44 0
1 0 16244 148140 104760 118368 0 0 0 0 18485 19851 25 2 72 0
1 0 16244 148140 104760 118368 0 0 0 0 1039 29 17 0 82 0
2 0 16244 144692 104768 118360 0 0 0 56 14790 16020 19 2 79 0
1 0 16244 143188 104772 118356 0 0 0 0 17587 18431 29 3 68 0
1 0 16244 143560 104772 118368 0 0 0 0 1077 38 14 0 85 0
1 0 16244 143568 104772 118368 0 0 0 0 1025 26 20 0 79 0
1 0 16244 143568 104772 118368 0 0 0 0 1029 23 11 0 89 0
I have these settings in /etc/mysql/my.cnf
key_buffer = 16K
max_allowed_packet = 1M
thread_stack = 128K
table_cache = 4
sort_buffer = 64K
net_buffer_length = 2K
The website does not get particularly heavy use, and this has only recently started to occur.
Does anyone have any advice on how the cpu usage can be reduced?
3 Replies
mysqltuner.pl
Enabling the slow query log in MySQL is a very good way to very quickly find out what is taking a long time, too. However, it'll catch a single query taking 100 seconds, but it won't catch a thousand queries taking 100 milliseconds.
Also, the usual database optimization stuff applies: make sure you're caching expensive and frequent queries, use indexes properly, and don't ask for data you don't need.
The website probably only serves 500 pages a day and the odd thing is that most of the e-mail alerts I receive are for between 3-5am in the morning or 5-7am in the morning. Today was the first alert I have received for a period when I would expect people to be on the website 10am-12pm.
I’m not a db expert so I am not sure about the caching. I will discuss the prestashop setup with the guy who put the site together, but I remember adjusting some prestashop files to speed the site up for production.