wordpress shared hosting performance

It’s the second week of running WordPress, so I’ve been trialing a few plugins…  Suddenly, about half the time I do anything I get “Apologies, but the page you requested could not be found.” The page loads fine the second time with a simple page refresh.  The site is brand new, so there shouldn’t be any traffic.  So what gives?Getting on-chat with DreamHost support (which itself is a great service)… five minutes later they had tracked down that my WordPress was exceeding the user RAM limit on their shared-hosting.  The system process watcher ProcWatch was killing off the connection.  Here is the log message supplied by DreamHost:

2011-03-10 03:55:15 procwatch2 INFO: Process(pid=1755, name='php5.cgi',
uid=xxxxx(10537396), tty=None, cpu=2.0, rss=42516.0, vsize=148964.0):
kill for total RAM

And one of many messages from file: logs/http/error.log:

[Thu Mar 10 04:01:59 2011] [error] [client 124.169.187.59]
Premature end of script headers: symposium_bar_functions.php,
referer: http://blog.openinworld.com/2011/03/morphic-performance-testing

Keeping the system balanced for all tusers is fair – but how does that affect me directly?  Am I able to work with this?  WordPress appears to put a relatively heavy strain on server memory.  I did not anticipate it the memory limit could be exceeded so easily, but I guess that is the reality of shared hosting.

DreamHost refrains from specifying what the RAM limit is.   Perhaps its dynamic, or a marketing issue, or it changes with time.  I’ve seen speculation elsewhere of it being 100MB, 120MB & 200MB in posts from 2006, 2010 & 2007.  From a shell with the `top` command I monitored my live processes.  How to Profile Memory in Linux describes the columns below.  Specifically we are interested in the resident memory.  Three WordPress php5.cgi listeners are shown, each idling comfortably around 45MB.  That might peg the RAM limit somewhere between 150MB to 200MB.

`top` command at the time that 14 plugins were installed

Interestingly, comparing this to the `top` snapshots at DreamHost WordPress Optimization I note the RES memory there is around 7.5MB versus my 35MB.  While part of this may be be due to general software bloat between versions, I suspect it may mostly be from RAM usage doubling between 32-bit and 64-bit operating systems.  Hopefully the RAM Limit was doubled accordingly to compensate.

So what to do? The simple suggestion from DreamHost was to “disable all your WordPress plugins.“  That seemed a bit extreme, but will at least help to understand the issue.  Before anything else, I went looking for a WordPress plugin to show plug-in memory usage. I installed TPC! Memory Usage (TPCMU), which immediately started firing the following email at me several times a second.  Note that the 32MB is a user defined soft limit.

WordPress memory usage exceeded 32 MB
WordPress peak memory usage: 34.85 MB
Number of database queries: 36

I then removed every plugin except TPCMU , and `top` then reported RAM usage 10MB better per listener – at around 35MB each.  TPCMU reported WordPress peak memory usage as 22.4MB. 

top2 with 0 plugins

top2 with 0 plugins

To observe the effect of reinstating each plugin, I tracked the Memory Usage displayed in the footer of the Admin > Plugins > Active Plugins page.  The results are tabulated below.  Marked in red are the plugins I ultimately removed, judging that functionality gain not worth the pain of required RAM.  I believe that remaining plugins are a reasonable balance of functionality versus memory usage  – particularly since two thirds of that is aimed at performance and security, with an overall benefit to other users of the server.

PLUGIN KEEP (MB)
REMOVE (MB)
Performance
TPC! Memory Usage
WP Super Cache 2.3
Security
Akismet 0.4
NoSpamNX 0.2
CryptX 0.3
Exploit Scanner 0.6
SI Captacha Anti-Spam 0.5
Publishing
After the Deadline 0.2
TinyMCE Advanced 0.1
Postie 0.8
User Experience
Sidebar Login 0.2
Email Login 0.1
Login Logo 0.05
Subscribe To Comments Reloaded 0.3
Breadcrumb NavXT 1.0
WP Super Mailer 0.5
Drop-zone 0.6
Subscribe2 1.8
WP-Symposium system 2.4
WP Forum Server 1.6
Admin
Open Web Analytics 0.06
WordPress Database Backup 0.6
Role Scoper 3.7
Broken Link Checker 3.8
Extended Comment Options 0.3
WP Stats 0.4
WP Stats Dashboard 1.8
TOTAL 5.6 19.0

TPCMU now reported 28.5MB and `top` showed php.cgi at 41MB.

I saw several tips suggesting that rather than just deactivating plugins, deleting them saves more space. I had 42 Inactive plug-ins, including those just deactivated and others I had tried and not liked.  Deleting all of them only reduced the TPCMU report down 0.1MB to 28.4MB – not much really.

DreamHost has some community information available.  DreamHost WordPress_Performance discusses page load speed. It recommends a few caching plugins and the use of FastCGI.  Faster processing reduces overall memory usage somewhat due to there being less concurrent php.cgi processes.

DreamHost WordPress Optimization discusses four site configurations in relation to memory usage.  It also recommends caching.  However it recommends NoFastCGI saying:

[Cache + NoFastCGI] has great performance while having the lowest overall resource hit on the server. It should always be using the least amount of memory and CPU time that it possibly can [...] whereas in a FastCGI configuration the number configured to spawn would remain open whether or not any requests were coming in.

When idle, FastCGI processes sit around continuing to consume memory.  Hence the cumulative memory usage over time would be greater than NoFastCGI.  That could be considered a greater load on the server.   However FastCGI provides a more steady and predictable load, which is more desirable for tuning that one that fluctuates.  FastCGI should handle peak loads more gracefully.  NoFastCGI has a fairly important proviso…

The only time [Cache + NoFastCGI] might be less efficient is if a large number of un-cached pages are accessed simultaneously as a number of php5.cgi processes would spawn to handle those.

…in which case ProcWatch would assumedly start killing off random connections for exceeding the user RAM limit. For a high traffic site (wishful thinking!) FastCGI should handle each cache-miss faster, thus requiring less overall RAM with less chance of connections being killed.  Ideally, the number of spawned FastCGI processes could be limited to avoid a “Kill For RAM” scenario.  However I haven’t been able to determine how to limit the number of FastCGI processes spawned.

I might have to keep an eye on FastCGI though, since this  WordPress: PHP CGI vs PHP FCGI post  points to some issues with FastCGI – that I have not experienced that so far.

In conclusion, Dreamhost offer shared hosting that is unlimited in many of its (advertised) parameters.  However overall service capability is limited by the tightest constraint – which in this case is RAM – the one they don’t advertise (and neither does any other shaed host I’ve seen.)  To work within this limit and resolve the “kill for total RAM” issue, I have:

  • investigated the memory usage of WordPress plugins
  • reduced the number WordPress plug-ins
  • activated an application-aware cache “Supercache”
  • continued to use FastCGI (which is the DreamHost default)

In the end, these are only simple things – but I’ve learnt a lot along the way.  I was considering further action with some of the methods from the WordPress Optimization Bible, but my error.log file has been clear for a few days, so I’ll leave those for later.

beleive
This entry was posted in Admin and tagged , , , , , , . Bookmark the permalink.

10 Responses to wordpress shared hosting performance

  1. Soccerwidow says:

    Thank you for sharing your experience. The information is very helpful and I’m going to try the plugins to check my memory usage as I’m having loads of 500 Internal Errors which is really annoying.

    By the way, you’ve got a very good writing stile. I enjoyed reading your article, very clear and concise.

    Well-loved. Like or Dislike: Thumb up 6 Thumb down 0

  2. ayeni says:

    Thanks for the writeup. This error – [ HTTP Error 500.0 - Internal
    Server Error
    C:\PHP5\php-cgi.exe - The
    FastCGI process exited
    unexpectedly] suddenly sprang up when I installed wp symposium on one of my Wp sites. I have 3 running on the server

    Like or Dislike: Thumb up 2 Thumb down 0

  3. Pingback: wp-coder.net » Common WordPress Issues and How to Solve Them

  4. Pingback: A Free wordpress newsletter » Common WordPress Issues and How to Solve Them

  5. Sara Avery says:

    Thanks so much. I’m having the same problems and I’m grateful to see your investigative work. I agree you have a good writing style.

    Like or Dislike: Thumb up 0 Thumb down 0

  6. Frank Church says:

    For the price of a Dreamhost shared hosting you can get a VPS that will give you 512MB or more. Using Nginx will help here as well.

    Like or Dislike: Thumb up 1 Thumb down 1

  7. Dhruv says:

    Hi Ben,
    One of my friends was having exactly the same issue. Since he is a non technical person, he came to me to fix that. Your article has helped me in fixing this issue. I removed all unnecessary plugins and it worked. Thanks.

    Like or Dislike: Thumb up 0 Thumb down 0

  8. Praveen says:

    Please list some sites which provide WP Optimisation service.

    Like or Dislike: Thumb up 0 Thumb down 0

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Upload Files

You can include images or files in your comment by selecting them below. Once you select a file, it will be uploaded and a link to it added to your comment. You can upload as many images or files as you like and they will all be added to your comment.