High CPU and Memory Load on Ubuntu 12 and LAMP

Posted January 26, 2015 5.4k views

I have a droplet of 1 cpu 1 gb ram running ubuntu 12 (32 bit) and LAMP
And somehow i feel that the website is running so slow (wordpress with only 1 user and very few data because i’m still developing)
so i put Monit and it says:
Status Load CPU Memory Swap
Resource limit matched [0.19] [0.41] [0.22] 11.3%us, 1.3%sy, 0.0%wa 85.7% [879476 kB]

so put some 1Gb swap
and the cpu went as much as 98%
so i ran top and i see apache2 is using most of the memories

Any solution
I tried so many solution like limiting cpu etc but didn’t work

i’m a noob in linux and vps…so please be kind

  • So i disabled autoindex and made this kind of miodification
    StartServers 3
    MinSpareServers 3
    MaxSpareServers 5
    MaxClients 30
    MaxRequestsPerChild 0

    it was lowered down to around 50-60%, so i hope it won’t climb back, because as for now i barely have contents and user....

    Any specific suggestion to optimize my case?

    thank you

  • Now the cpu is 100% and the memory is 80%...........

  • I had similar situation where the load spiked drastically this morning. But have no definitive solution to help you other than maybe you could create an additional droplet and connect it to your main via a private network IP address and have it run some of the processes for your internet facing droplet.

    I personally use Ubuntu 14.04 LTS (LTS = Long Term Support) Ubuntu 12 is nearing its “end of life” cycle. Check out and loads of information and lots of tutorials. Another great site to help you with inspiration is it’s got lots of tutorials on building specific types of servers for Ubuntu and other OSes.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

so i checked, 3 of the most memory users are:

  1. apache2 (www-data) 10-20% Cpu Usage, 280-350 MB memory usage
  2. clamd (clamav) 0-10% cpu usage, 220-280 MB memory usage
  3. apache2 (admin) 0-15% cpu usage, 90-200 MB memory usage

is this normal? is there any way to improve this? please........

Finally this helped, none of other solution did any change (add swap, monitor for banned iP’s, upgrade droplet):

## Edit /etc/my.cnf, and add the following line under the [mysqld] heading.

Then restart: $ service mysql restart