My friends often ask me,
“How come your site has such a ridiculously small response time?
Only 200ms for WordPress, it cannot be real.”
Ok, my answer is “It can be real”. All you need is to pick best ingredients to make magic happen.
Here’s my recipe:
- Fast VPS – DigitalOcean
- Fast HTTP server – nginx+FPM
- Fast protocol – SPDY
- Minimalistic WordPress theme & minimal set of plugins
Let’s quickly review why all these ingredients are important.
Fast VPS – DigitalOcean
Ok, what would be the alternative? Shared hosting?
Pffft… Slow ftp access and hundred other sites sharing the same server affecting performance of your site? No thanks.
I’d better take VPS – virtual private server. With ssh root access, ability to install whaterver I need, and no other sites except my own ones to share it’s resources.
And why DigitalOcean? Ok on my developer machine – top notch Macbook Pro with 16gb ram and ssd harddrive I have virtual development server with pretty much the same configuration I have on DigitalOcean VPS. The difference is this VPS has 4 times less RAM and works at least 2 times faster than on my local machine. “Whoaaa” was my first reaction when I tried it first.
Fast HTTP server – nginx+FPM
The alternative is – ol’ rusty Apache HTTP server.
Why nginx better? In short, it uses memory and cpu more efficiently.
By the way in the tutorial ahead you’ll see that when picking predefined droplet software package we pick LEMP instead of WordPress. That’s beacause of “WordPress” package uses Apache, and we need nginx that is part of LEMP stack (LEMP – Linux, Engine-x, MySQL, PHP). It takes a little longer to set up but in the end you get more efficient solution.
Fast protocol – SPDY
SPDY or speedy, what’s that? Who cares, isn’t it awesome to have something speedy in your configuration?
I’m joking. SPDY is the extension to the ol’ rusty HTTP protocol. What’s wrong with HTTP? Well it’s ok, it served us well for a couple of decades. The only problem it has is a restriction of 6 concurrent connections max. It means that with http your browser cannot load all static resources (images, scripts, stylesheets) simultaneously, but has to load them sequentially.
But SPDY says “bring ’em all!”
Still there’s a catch. To use SPDY you need to enable HTTPS and for that you need SSL certificate, and that usally costs money.
But there’s a way to obtain SSL cert for free from startssl.com. This certificate will be good enough to show ‘secure’ icon in browser and to enable SPDY on your server, isn’t it awesome?
Minimalistic WordPress theme & minimal set of plugins
Why is that important? Ok in terms of php performance your WP site consists of 3 pieces:
- WordPress itself
- Visual Theme
- Set of plugins
You cannot modify & optimize WordPress Core. Well, in fact, you can, but when they issue a security update what you gonna do? So leave it to the WordPress team.
The rest part of site performance depends on WP theme & plugins.
The good news about WP is that there are thousands of plugins and themes. And that what WP users like a lot.
The bad news is that most of plugins and themes are developed by newbies who do not care about performance. To put it lightly.
The same is true for the paid themes. Unfortunately.
So the only solution is to pick your theme and set of plugins carefully. I’m gonna write an article how to do it in near future.