(last edited on April 29, 2014 at 1:27 am)
Some additional memory usage reductions I’ve made, after applying these configuration changes to my VPS at MediaTemple.
Limiting number of Plesk PSA connections
When you go to your Plesk administration page, you’re accessing a special webserver over SSL. The webserver process is httpsd
, and it’s larger than the stock httpd
process, using up another precious 30MB.
To reduce its memory usage, I’ve played around with reducing the number of clients it spawns and keeps around to 1. It never actually seems to drop below 2, but at least it doesn’t balloon up.
The Plesk-safe way to do this is to create a file /usr/local/psa/admin/conf/httpsd.custom.include
and add the following overrides:
MinSpareServers 1
MaxSpareServers 1
StartServers 1
MaxClients 1
KeepAlive On
KeepAliveTimeout 10
This reduces the number of services that are running to a minimum. Note that if you have other people running Plesk control panels, you may run into login problems and sluggish behavior if you reduce the # of servers by too much. In general it’s just me on my server, so I keep the numbers low.
Check that everything is ok with:
/usr/local/psa/admin/bin/httpsdctl configtest
Type free
to see how much used memory there is before you start, then restart the Plesk webserver (gracefully) with:
/usr/local/psa/admin/bin/httpsdctl graceful
Type free
again to see if you’re using less memory.
Disable Spam Assassin
SpamAssassin is a service that filters for spam on incoming mail, and each instance uses 21MB. I’m using other spam-prevention methods, so I’ve turned it off.
- To disable it in Plesk: Go to Server:Services Management and click the red STOP icon.
- From the shell: Type
/etc/init.d/spamassassin stop
from the shell.
To disable it permanently, remove execution permission from the spamassassin script by typing chmod a-x /etc/init.d/spamassassin
…you can always add it back by change the -
to a +
in the chmod
command example. Note: I haven’t tested this recently by restarting the server with the shutdown -r
command…I think it works.
Disable DNS Services
If you’re not using DNS on your (dv), then you might as well turn it off as it uses a smidgeon of memory.
- To disable it in Plesk: Go to Virtuozzo:System Services and click the named hyperlink. Click “stop service** and “disable autostart”.
- From the shell: Type
/etc/init.d/named stop
. You can also remove the execution permission from the named script to prevent it from starting on a server reboot.
In case you’re wondering if this will take your server down, note that Media Temple already provides DNS for your server, through the Media Temple AccountCenter. The DNS server settings in Plesk are for specialized applications that go beyond simple hosting. Your subdomains will not stop working.
UPDATES
The good folks at Media Temple have researched these tweaks themselves, and have released an official unsupported advanced method of doing it the right way! Awesome! :-)
15 Comments
Excellent Excellent Excellent. Thanks again David. I noticed myself that there were 4 or 5 plesk client process running.
Cheers
——-
so I disabled the DNS, so if im using google apps for domain and I have to edit the MX of my domain through account center?
I stopped the DNS service last night and now, I cant connect to plesk
Is that the reason why?
Ralph: It depends on how you set up your registrar settings. Your registered domain record is maintained by a domain registry, which points to a pair of name servers that are responsible for converting your domain name to a numeric IP address.
There are two ways you could set up your domain name registry:
<ol>
<li>Use Media Temple’s name servers, which are ns1.mediatemple.net and ns2.mediatemple.net.</li>
<li>You use your dv as the name server, which would be something like ns1.yourdomain.com.</li>
</ol>
It’s not very clearly documented at all that these are your options, and I though I needed to configure through plesk. After thinking about it for a bit, I realized that I could just use MT’s name servers and not have to worry about maintaining my own DNS on my own server. For one, it uses up my memory…much better to use MT’s servers.
To re-access your plesk, just connect to the numeric IP of your server on port 8443. It should be in your welcome to media temple email.
Thank you Dave. Wow, great tutorial. I did both optimization sets you posted. I run free and notice an improvement but I don’t know why my wordpress is soooo slow. I have these plugins:
-Ultimate Tag Warrior
-wp-cache
-WP-EMail
-WP-Polls
-WordPress Database Backup
Even when I turn them off its slow. I’m hitting a wall. I’m running a MediaTemple DV Base.
btw – What do you use for spam?
Thnx again,
-d
I took a quick peek at the source code; have you tried disabling the javascript? You are running some pretty large javascript libraries that are known for being pretty piggy; if I disable javascript in Firefox, the pages load VERY fast.
For spam I’m using “Close Open Posts”, “Bad Behavior”, “Akismet”, and “SPAM Management and Prevention”. Prior to installing Close Open Posts, I was still getting about 1000 spams a day (50% making it by Bad Behavior). They are almost all trapped my Akismet. I use the management plugin to delete them (it’s not quite perfect though).
Dave. Thanks a million! I must have become accustomed to JS. With the wp-cache plugin the pages fly now. I added a conditional check for the portfolio section (only page that need the scripts). I’ll have to cleanup the naughty js later.
btw – I love your header image. looks like my desk :). “They’re paper weights” I tell my wife.
your the man.
-d
Hi David,
Excellent suggestions btw.
What do you use instead of SpamAssassin as methods to block email spam? I find SpamAssain would block 98% of incoming spam. I use ThunderBird for an email client.
SS: I actually disabled SpamAssassin as it seemed suck down too much memory and CPU and not stop much. I’m thinking of transitioning my mail mail servers off my (dv) to other services that have spam-fighting infrastructure in place, but haven’t moved on it.
I just implemented all these changes and saved 60-70 megs of ram. whoot! Thanks Dave, I’ll be doing the same with your other optimization post.
Hi David,
Great articles! But….
While it may be a good idea to strive to reduce memory usage, there is a huge flaw in your idea that you should strive to stay within 256MB… there is in fact no 256 MB of RAM magically set aside for your dv base server at MediaTemple.
Instead, there is a minimum allocation of RAM plus swap that is set at no more than 120 MB!
Yes, it’s sad but true. We may have signed up for our dv base servers thinking that we would be guaranteed a minimum of 256 MB of actual RAM (like the MediaTemple ads say), but alas that’s simply not the case.
The values of vmguarpages and oomguarpages define the minimum allocation as a total of RAM plus swap of 30000 and 28729 (4096 byte pages)… which means that when push comes to shove, in a moment of resource shortage, our base dv servers may be forced to operate with a total allocation of less than 120 MB of ram PLUS swap… in which case various programs may be terminated by the server in order to stay within that meager minimum.
So… yes it’s a great idea to strive to reduce memory usage, but there is no truth to the idea that the base dv at MediaTemple is guaranteed 256 MB of RAM. (despite the fact that the MediaTemple advertising specifically says 256 MB RAM)
As a confirmation of this, I have just received a note from Yuri Litvin, Systems Engineer at MediaTemple who says:
“The lower limit is set to ~120MB (vmguarpages & oomguarpages ) and that’s the amount that is always guaranteed to your server. The upper limit is what your server can have at the maximum and that is set to ~690MB. We don’t necessarily limit your (dv) at 256MB, so at peak times you can allocate and use more, but we do guarantee that you have at least ~120MB at all times
We’ve been monitoring our (dv) servers ever since we’ve started offering them and we’ve never run into problems of people actually being denied memory allocations at the limits we advertise. All of the (dv) servers are very under-utilized and we keep a close eye on them to monitor for any abuse.
One easy way to monitor your memory allocation is to watch for “failcnt” in /proc/user_beancounters. If you start getting them, let us know and we will review your memory usage.”
The tutorial was ace, Keep up the good work.
Thank you, i have a little more memory :o)
It’s 2013 and I’m just seeing some of these 2008 comments! :) Regarding Richard’s comment on the flaw in keeping to 256MB because we’re not guaranteed to get that full amount anyway, that’s a good argument. However, it misses the point of why I’m doing it.
The reason I’m tuning my processes to stay within 256MB is because the server is far more likely to stay stable under heavy load, like a huge traffic spike. Running out of memory is a guaranteed way to kill the server as it starts using secondary memory sources that are orders of magnitude slower. Tuning the process profile to stay within 256MB makes that unlikely to happen. The server may get SLOW or run out of connections, but it won’t CRASH under the strain by overbooking processes that are running so slowly that they bottleneck everything.
That’s the general idea.