Many common issues with Linodes are caused by excessive memory consumption or networking configuration errors. This guide provides suggestions for alleviating these problems.
When your VPS is running low on physical memory, it may start to "swap thrash." This means it's attempting to use your swap partition heavily instead of real RAM. We recommend you limit your swap partition size to 256 MB; heavy use of swap in a virtualized environment will cause major performance problems.
We strongly recommend running the 32-bit version of your distribution of choice, unless you have a specific reason to run the 64-bit version. The 32-bit version of your distro will use significantly less memory.
You can use the following command to display memory use on your Linode:
free -m
You can use the following snippet to see a list of your running processes sorted by memory use:
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less
To see IO activity on your VPS, you may use the following command (you may need to install the sysstat package under Debian or Ubuntu first):
iostat -d -x 2 5
This will give an extended device utilization report five times at two second intervals. If your VPS is OOMing (running out of memory), Apache, MySQL, and SpamAssassin are the usual suspects.
In your MySQL configuration file (typically found in /etc/mysql/my.cnf), change your entries for the various settings shown below to match the recommended values:
key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K table_cache = 4 sort_buffer = 64K net_buffer_length = 2K
If you don't use InnoDB tables, you should disable InnoDB support by adding the following line:
skip-innodb
Determine the type of MPM in use by your Apache install by issuing the following command. This will tell you which section to edit in your Apache configuration file.
Debian-based systems:
apache2 -V | grep 'MPM'
Fedora/CentOS systems:
httpd -V | grep 'MPM'
In your Apache 2 configuration file (typically found at /etc/apache2/apache2.conf in Debian and Ubuntu systems, and /etc/httpd/httpd.conf in CentOS and other similar systems), change your entries for the various settings shown below to match the recommended values.
StartServers 1 MinSpareServers 3 MaxSpareServers 6 ServerLimit 24 MaxClients 24 MaxRequestsPerChild 3000
If you're filtering mail through SpamAssassin in standalone mode and running into load issues, you'll need to investigate switching to
something to keep the program persistent in memory as a daemon. We suggest looking at amavisd-new
.
If you've added multiple IP addresses to your Linode, you must set up static networking as described in the Linux Static Networking Guide. Please be sure to specify only one gateway. Using multiple gateways frequently causes problems.
If you just added an IP address to your Linode, please be sure to reboot before attempting to use it. This is required to properly route the IP address on our network.
If you've added a private IP address, please be sure to use the network settings shown in the Network tab of the Linode Manager, paying special attention to the subnet mask. Note that private IP addresses do not require a gateway (nor should one be specified).
This guide is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States License
.
Please feel free to redistribute unmodified copies of it as long as attribution is provided, preferably via a link to this page.
|
|
Submitted by pparadis on Thursday, August 13 2009 at 12:55:44 GMT
@neter: Thanks for the contribution!
|
|
|
Submitted by pzn on Monday, November 16 2009 at 10:51:24 GMT
If you have problems with apache getting too much memory, and your needs are simple, try removing apache and installing lighttpd. It uses just a small ammount of memory. I run cgi and php in lighttpd.
my lighttpd uses: rss=1568kb vsize=4640kb |
|
|
Submitted by John on Friday, December 11 2009 at 00:14:48 GMT
If you are using Phusion Passenger see PassengerMaxPoolSize. This will greatly reduce memory consumption on smaller slices.
http://www.modrails.com/documentation/Users%20guide.html#_passengermaxpoolsize_lt_integer_gt You can also use ps_mem to identify processes that are candidates for investigation. http://www.pixelbeat.org/scripts/ps_mem.py John |
|
|
Submitted by Jeff on Monday, January 4 2010 at 19:03:51 GMT
What are the performance implications of making those changes to the MySQL settings?
|
Got a comment?