My wordpress blog keeps getting killed

I write a blog that gets about 100 hits daily, but every so often I'll get picked up reddit or some other big site and my site promptly dies.

I'm running Ubuntu 8 LTS, apache2, mysql, and wordpress. What should I do to improve my site?

7 Replies

Another option is to use the Coral cache. It's simple; all you do is add .nyud.net to the end of the hostname - for example, http://foo.example.com/bar/baz.php becomes http://foo.example.com.nyud.net/bar/baz.php .

Of course, using this without any work on your part means convincing people to use the Coralized URL when submitting your pages to Digg or whatever. As an alternative, see the section "Coralizing certain referrer sites" at http://wiki.coralcdn.org/wiki.php?n=Main.Servers – you'll still get hits on your machine, but processing and sending clients a redirect should be easier on it than processing and sending the whole page.

Here's what I would do:

1.) Install wp-super-cache: this caches full pages and it's ideal for situations where you're getting a ton of visits to only a small number of pages. When you serve a page, most of the time php code won't even be executed meaning you don't have to worry about php object caches or tweaking mysql.

2.) Serve all your static content (images, css, js) from a lightweight web server like nginx. This isn't really "faster" than apache, but it does use a whole lot less memory so you can serve way more visitors.

Implement those two changes and you should be able to handle reddit level traffic on even a linode 360.

@Vance:

Another option is to use the Coral cache.
A small advisory: Coral Cache is filtered by default by a lot of Web censorship gear. I know WebSense does for a fact.

(They had to work around kids typing myspace.com.nyud.net.)

Define more specifically what you mean by "my site promptly dies."

My very first suggestion is to install munin so you have trending on load and resource usage during good times and bad.

My next suggestion is to install the php-apc package. This saves PHP the problem of reparsing all the wordpress code files for each new request. In my testing, this easily cuts the per-page response time in half on an unloaded Wordpress site with a handful of plugins, and, as I recall roughly doubled throughput under load. The cost is some memory for the cached code, but for Wordpress, I think that is only 10-15MB, and it is shared across all the apache processes.

Once you have some data in munin you'll be better able to figure out where you should focus next. I'd guess though that under high load you end up with more apache processes than are really useful given the amount of memory you have on hand. Evidence of this would be less than full CPU utilization during traffic spikes, little or no "free" memory allocated to file cache or buffers, and a big jump in the use of swap space.

Next, I'd turn of HTTP keep-alives in apache, or reduce them a few 10s of miliseconds, otherwise, apache processes end up sitting around wasting memory waiting to see if a client is going to make another request.

Something like wp-super-cache can help, but I found that it resulted in odd behavior. The quirks would be acceptable during periods of high load, but I think you'd have to turn it on and off manually. I wouldn't mess with Coral cache, unless it was for a big file or something. Its a cool idea, but if you use it, you loose SEO benefits of being linked to, data about your users, etc.

As others have suggested, its worth using nginx or something similarly efficient to serve static content. I'd go even further and say its useful to have it reverse proxy dynamic content. Doing so means apache can move quickly on to serving the next dynamic request, rather than wasting memory for ~100-300ms waiting to return the output of the php script to the client. Nginx can also take care of the http keep-alives efficiently. I posted information about configuring nginx to front-end for apache+php+wordpress in this thread: http://www.linode.com/forums/viewtopic. … 2010#22010">http://www.linode.com/forums/viewtopic.php?p=22010#22010

1) Check the MaxClients setting for Apache. The defaults on most distros are far too high for anything with less than a GB of memory.

2) If you're not using InnoDB tables turn in skip-innodb for MySQL. That saves about 5%-10% of memory on a Linode 360.

-James

Switch to NGinx + Apache Proxied + Wp-SuperCache

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct