Ubuntu server unstable performance

I am experiencing frequent drops in performance of my server (affects both webserver performace and ssh). It may work fine all day and then suddenly pages load 10 times slower. After awhile it comes back to normal performance. Reboot also helps. Please suggest how to investigate this? Prerequisites:

  • Ubuntu 10.10 server, with most recent updates (including kernel)
  • LAMP: Apache/2.2.16, PHP 5.3.3, MySQL 5.1.49

1 Answer

There are multiple possibilities for degrading performance, but the most likely cause is a shortage on RAM, causing the system to swap.

You can use free -m to get the memory usage, an example output:

 total used free shared buffers cached
Mem: 3632 2512 1120 0 233 1456
-/+ buffers/cache: 822 2810
Swap: 8192 0 8192

The actual free space that can be allocated is visible on the row with -/+ buffers/cache. If you find that your server is swapping too fast, you might want to lower the vm.swappiness setting. You can find your current swappiness setting by running sysctl vm.swappiness. It ranges from 0 - 100, a lower value will use the swap later, a higher value make the kernel use the swap earlier. If you decide to set this value to 10, you should run the next command to change it at run-time:

sudo sysctl -w sysctl vm.swappiness=10

To make it persistent (i.e. after a reboot), add the line sysctl vm.swappiness=10 to /etc/sysctl.conf.

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like