My Ubuntu 18.04 server with 2GB of RAM and 2 CPU cores experiences major CPU load spikes when someone accesses the Wordpress site that the computer serves. This slows down the website very much.

Below is the output from a top command

top command output

In the screengrab above, the load is shown to be 3.8, but most of the time it rises to 5.0 - 6.0.

The server runs Apache2 in Event MPM, MySQL 8 and PHP7.3. Redis caching is also present.

Due to this load spike, my website times out with a Cloudflare 524 error and I'm unable to log into wp-admin.

Is there any way to fix this?


Here is a link to the output of the MySQLTuner tool run on this system. https://pastebin.com/awxRidr3

And here is the link to the output of cat /proc/meminfo. https://pastebin.com/E9uvq5A9

  • Page caching for anonymous users can provide a good speed-up, since most Wordpress sites are mostly status. Use CloudFlare to do caching of static resources. My Amazon Linux server has 5% of a CPU core (bursting to 100%), 512MB RAM, 512MB swap, and serves six low traffic websites easily. Wordpress / PHP is VERY CPU hungry, but it shouldn't stop you SSHing in if it's busy. Reduce the number of PHP workers to the number of threads your computer has to prevent overloading the system. – Tim Dec 12 '19 at 23:32

Performance issues can be any number of things. Investigate everything and keep an open mind.

73% IO wait suggests the storage system is a limiting factor.

Install bpfcc-tools and run filetop to see reads and writes by file. Classify what gets lots of I/O: database, uploaded content, the web application, whatever. Use ext4slower (or xfsslower) scripts to find file system operations that take more than a few milliseconds.

Possible actions:

  • Migrate to solid state disks if you have not already
  • Enable and review the slow query log
  • Consider a separate database host, possibly a managed service
  • Find some of the many WordPress checklists and evaluate their suggestions
  • Do a capacity analysis and determine if it is time to scale out or up.
  • Thanks for the answer! I think the drive that the OS and all the software is installed on is the major bottleneck. I am currently using a USB memory stick to run Ubuntu. I think I should definitely invest in an SSD upgrade. I do have a 40GB HDD (really old), do you think that it would be faster if I use the HDD while I source an SSD? – SidS Dec 7 '19 at 15:38
  • I wondered why there was a usb-storage thread in state D. Try everything you have, spindle and solid state. Typical USB storage sticks have miserable write performance. Although one spindle would be less than 100 IOPS and not amazing either. – John Mahowald Dec 7 '19 at 19:44
  • 1
    (As a stop gap measure) Do you have swap enabled? Try changing VM.swappiness to 5. – davidgo Dec 7 '19 at 20:31
  • Please post COMPLETE MySQLTuner.pl (perl) report after 24 hours of UPTIME so we get some idea of your use of MySQL. With a 2G server size, why would you need to use KHUGEPAGED? Disable anything HUGEPAGE, you do not have the RAM to support it. – Wilson Hauck Dec 8 '19 at 13:58
  • @davidgo I do have swap enabled, I will be moving to the 40GB HDD, that should make things faster, if it doesn't I might as well disable swap. – SidS Dec 8 '19 at 21:29

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.