We've been running a Magento 1 site for over 7 years and although cpu usage has been quite high, it's not been a concern as performance seemed fine even, it is a high traffic site after all.

Preparing to move over to Magento 2 we installed the latest version (2.3 at the time) and ran it in developer mode along with the M1 site with no hit on server performance.

Now we've finally switched fully to M2 and enabled production mode, wow, cpu usage has gone off the chart https://imgur.com/a/F5w5P7a

I've followed a few suggestions on here regarding enabling caches etc and nothing improves. Thinking M2 would be a much more stable and 'optimised' system, we're not impressed at the moment!

Any suggestions would be very welcome. It's a single server, 16GB ram, 6 Core, Apache/PHP 7.2/MYSQL.

  • Additional information request. 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; AND Optional very helpful 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 Oct 17 at 14:40
  • Is debug mode turned off on M2? – Wilson Hauck Oct 17 at 14:47
  • 1
    Thanks for taking the time to reply Wilson. Storage is an SSD yes. Debug mode is disabled. Hopefully these links work. pastebin.com/J9iFvbiA imgur.com/a/NcYWCDD – AndyS Oct 18 at 15:48
  • Thanks for posting the additional information. Analysis in process. – Wilson Hauck Oct 18 at 17:37
  • 1
    Sure thing: pastebin.com/k9GpiJBb Regarding normal ops, I can only say yes as it's the main website with little else on the server and traffic is fairly consistent. Weekends can be busier. – AndyS Oct 19 at 10:45

Rate Per Second = RPS

Suggestions to consider for your OS Open Files limit,

From OS command prompt, ulimit -n 128000 and press Enter to enable more than 1024 Open Files as reported by ulimit -a output. This is a dynamic variable and does not require OS restart.

For this change to be persistent across OS shutdown/restart's review this URL, please. https://glassonionblog.wordpress.com/2013/01/27/increase-ulimit-and-file-descriptors-limit/ Use 128000 rather than 500000 as in the example. This will enable MySQL to support 96000 open_files_limit to avoid Open Table THRASHING and manage the Apache software requirements for file activity.

Suggestions to consider for your my.cnf [mysqld] section

open_files_limit=96000  # from 1024 to reduce Open Table Thrashing. 
innodb_open_files=40000  # from 407 to better support your 51 max_used_connections. 
table_open_cache=40000  # from 407 to reduce opened_tables RPS of 56. 
table_definition_cache=2400  # from 603 to reduce opened_table_definitions RPS of 23. 
innodb_io_capacity=1900  # from 200 to allow more SSD IOPS utilization.

Some of these variables are static and I would recommend making all of them, then SHUTDOWN and RESTART your MySQL instance.

AndyS, For your busy system there are many more areas to be considered/tuned. Please view our profile for contact information and consider using our free downloadable Utility Scripts to assist with performance tuning. Comments after application are appreciated with positive/negative feedback.

| improve this answer | |
  • Sincere thanks for your time and suggestions Wilson, I will make those changes today and monitor the server performance. I'll certainly follow your links too and hopefully learn something from this experience. Again, thank you – AndyS Oct 19 at 14:30
  • A quick update.CPU usage has remained high so further investigation needed imgur.com/a/El6ghif – AndyS 2 days ago
  • A part of the answer includes - For your busy system there are many more areas to be considered/tuned. – Wilson Hauck 2 days ago
  • Andys, What is result of SHOW GLOBAL STATUS LIKE 'uptime%'; ? Are your queries completing faster with the reduction in opens? – Wilson Hauck 2 days ago
  • Andys, Please also post TEXT results of SHOW GLOBAL STATUS LIKE '%open%'; as well as the uptime results to allow calculation of current RatePerSecond for the variables that will be listed. Thanks – Wilson Hauck yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.