1

I have a Laravel application running on my Ubuntu 18.04 server and MySql 5.7. Sometimes, it is very slow. I have checked with "top" command and this is the result:

enter image description here

Some times %cpu raises over 140% for mysqld command, and i presume this is the reason for very slow site (I thhink this is the cause).

I have root access to SSH, if someone needs more informations (I'm new with Linux/nginx).

What should i do to solve the problem?

pasluc74669
  • 111
  • 2
  • 1
    High CPU (or Load Average) almost always means a slow query -- Find it and provide `SHOW CREATE TABLE`. – Rick James Dec 19 '20 at 18:45
  • 2
    Your system has 16GB of RAM and your MySQL instance uses only 409MB and a few hundreds of MB for php-fpm and system processes. It seems that 90% of your system resources are underutilized. – AlexD Dec 19 '20 at 19:07
  • First try to enable slow_query_log in my.cnf to check which query is taking a lot of time and see if you can optimize it. Also you might check the output from SHOW VARIABLES and SHOW STATUS and raise the memory limits for mysql - innodb_buffer_pool_size and key_buffer_size variables will be a good start depending on your storage engine. The "mysqladmin extended-status" command can also be used to see MySQL status details. – Dobromir Velev Dec 20 '20 at 05:58
  • 1
    @AlexD thank you for your response. How can I increase MySQL instance memory, to optimize the system that have 90% of resources underutilized? – pasluc74669 Dec 20 '20 at 09:46
  • 1
    @pasluc74669 MySQL tuning questions are more suitable for dba.stackexchange.com. In your case setting `innodb_buffer_pool_size` to 50-75% of your RAM should give the most performance improvement (but only if you are using InnoDB). – AlexD Dec 20 '20 at 10:44
  • Additional information request. # cores, any SSD or NVME devices on MySQL Host server? Post on pastebin.com and share the links. From your SSH login root, Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; E) STATUS; G) SHOW ENGINE INNODB STATUS; AND Optional information, if available includes - htop OR top for most active apps, ulimit -a for a Linux/Unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, for server workload tuning analysis to provide suggestions. – Wilson Hauck Dec 25 '20 at 01:49
  • Your URL in your profile is not available today. You may want to update your profile. Welcome to serverfault. – Wilson Hauck Dec 25 '20 at 03:00

0 Answers0