MySQL service crashing a lot on your new VPS box? Unwilling to pay even more for an appropriate amount of memory that’s needed to support WHM’s [mostly] default configuration? The guide below might just be the solution you’re looking for. I hope it is and that you found it on your first Google search.
I wish that had been the case for us, but my pain is [hopefully] your gain.
Optimizing Memory Usage on a WHM/Cpanel VPS Server
WARNING: The following tweaks require a sound understanding of your VPS server and WHM/Cpanel. Some of the tweaks below WILL cause problems if your environment and/or website is dependent on them. Proceed at your own risk with extreme care and take a freakin backup.
Environment We Ran These On:
CentOS 6.7
WHM 11.50.2
2.4 Ghz Dual Core Processor
1 Gig of RAM
1 website being hosted – A high traffic WordPress based site
- Optimize MySQL: By far the most impactful of the configuration tweaks we implemented (300mb+ reduction in idle server memory usage)
- For MySQL 5.6.6 +, turn off performance_schema . This is turned on by default in 5.6.6+ and seems to eat RAM for breakfast (more info on this)
To disable performance_schema:- Open my.cnf (typically @ /etc/my.cnf) via SSH or VPS admin panel » add the following line just under [mysqld] » performance_schema=0
- Save/close my.cnf and restart mysql service
- For VPS server’s with very limited memory, high traffic and/or a lot of MySQL databases convert InnoDB tables to MyISAM. This might impact load times slightly, but it also allows the converted database tables to be accessed with a much lower memory footprint . You can do this on each table in PhpMyAdmin or with scripts. Google it.
- For MySQL 5.6.6 +, turn off performance_schema . This is turned on by default in 5.6.6+ and seems to eat RAM for breakfast (more info on this)
- Stopping SpamAssassin: This program isn’t overly important to the stopping of spam. To turn it off do the following:
- Go to WHM » Server Configuration » Tweak Settings » Disable Spamd
- Go to WHM » Service Manager » Disable Spamd
- Stopping Mailman: If you or none of your customers are running e-mail accounts through cPanel, it would be a good idea to disable Mailman (this will not affect web-forms being sent out).
- Go to WHM » Server Configuration » Tweak Settings » Disable Mailman
- Stop ClamAV: Never use ClamAV on a VPS server unless you have memory and cpu cycles to spare (and why are you reading this if that’s the case?).
To disable ClamAV:- Go to WHM » Home » cPanel » Manage Plugins » Uncheck clamavconnector and save.
- Disable Catch All E-Mail Delivery : If you are getting a lot of spam for non-existent e-mail addresses, disable their delivery.
To disable catchall email delivery:- Go to WHM » Server Configuration » Tweak Settings » Mail » Initial default/catch-all forwarder destination » Change to :fail:
- Tweak Apache: Apache needs some tweaking to reduce memory usage.
Recommended settings updates for this:- WHM » Home » Service Configuration » Apache Configuration » Global Configuration » Change the following settings:
MinSpareServers 2
MaxSpareServers 5
StartServers 3
Keep-Alive Off - Save the values and rebuild apache (rebuild should start automatically).
- WHM » Home » Service Configuration » Apache Configuration » Global Configuration » Change the following settings:
- Optimize PHP – Main advice here would be to reduce memory_limit in php.ini file. This wasn’t an issue for our server, but might be worth checking if everything before now hasn’t helped enough.
To reduce memory_limit:- From WHM >> Service Configuration >> PHP Configuration Editor >> Core >> memory_limit
After making all the tweaks, reboot your VPS, check memory usage. Hope it has freed up enough to get your server stabilized!
To check memory usage:
From SSH àfree –m
From WHM à system health à server status
I think a dollar for every MB you freed up is reasonable, but am open to cookies, toys, compliments, trolling and comments as well.
Sources:
– http://syslint.com/syslint/how-to-reduce-memory-consumption-on-a-cpanel-vps/
– http://blog.triantech.com/memory-drain-issues-on-mysql-5-6/
– http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-optimization-tips.html
– http://www.vpshostingreviews.net/whm-tutorial-tweaks-for-vps-performance-optimization/
Recent Comments