SlideShare a Scribd company logo
EAST BAY WORDPRESS MEETUP

HOW TO MAKE WP FLY...
LIKE A BAT OUT OF HELL

Sunday, October 6, 13
EXPLAINING
THE SECRETS
BEHIND MANAGED
HOSTING AND REALLY
FAST WORDPRESS SITES

THE ALTERNATIVE TITLE
I could have renamed this presentation
Sunday, October 6, 13
Stefan Didak
http://www.stefandidak.com
(“not a web developer”)
Sunday, October 6, 13
The sound a WordPress site
should make when your client is
happy to pay you more because
their site is so fast that it puts
their competition to shame.

TIME = MONEY
Sunday, October 6, 13
Caching provided by optimizing your site
Caching through plugins
Caching because of all of the above
As you’ve already been shown today

LEVELS OF CACHING
all of those make a difference but... NOT ENOUGH
Sunday, October 6, 13
Don’t just optimize your site
Optimize YOUR SERVER!
and if you have none, build one!
Optimize YOUR CODE TOO!

LEVELS OF CACHING
Everything I’m going to show today requires you to have full
control and access to your server (VM, VPS, Cloud, etc.)
Sunday, October 6, 13
WordPress Caching
Digital Ocean + DEMO
OpCode Caching
Apache v.s. Nginx
Varnish
Memcached
WHAT I’LL BE COVERING
Also known as the Tip of the Iceberg
Sunday, October 6, 13
WP CACHING OVERVIEW
Everyone should know what levels of caching WP supports
Sunday, October 6, 13
Only lasts the duration of the request.
After the request the run-time cache no
longer exists.
For example: the global $post and
$wp_query variables

WORDPRESS CACHING
Run-Time Cache
Sunday, October 6, 13
WordPress has a “Transient Cache” API
that allows you to store data in
your MySQL DB.
Ahum... Right...
But it can still be useful...
if used selectively

WORDPRESS CACHING
Transient Cache
Sunday, October 6, 13
Is usually persistent because it’s stored
“somewhere”.
Somewhere could be in memory through
APC, Memcached, or Redis, but could also
be in your MySQL DB or on disk.

WORDPRESS CACHING
Object Cache
Sunday, October 6, 13
Stores HTML data representing entire
pages. This is one of the more typical
caching schemes used by most plugins.
Unfortunately, not so useful when you have
highly dynamic pages where someone does
not always get the same content (i.e.
membership sites).

WORDPRESS CACHING
Page Cache - Stored on disk or in memory
Sunday, October 6, 13
I don’t like the term and it is no different
from the Object Cache. Instead of storing
entire HTML pages it stores parts of pages.
I like to think of it as just another object
because that’s what it is.

WORDPRESS CACHING
Fragment Cache
Sunday, October 6, 13
I prefer to have full control
over my own online servers
because I can have them be
faster than managed hosting
at a fraction of the cost.

PERSONAL EXPERIENCE
Managed Hosting, however optimized, is still designed to be a
version of a “one size fits all” approach
Sunday, October 6, 13
GREAT(ER) PERFORMANCE
& OK PRICES
GREAT PERFORMANCE
& COOL PRICES

SLOW & EXPENSIVE

Sunday, October 6, 13

NICE PERFORMANCE
& CAN GET EXPENSIVE
After running and testing my first
“droplet” on Digital Ocean and after
playing with some deployments on
Linode I knew my shared hosting for
30+ domains would come to an end.
A very WELCOME END!

FIRST DEPLOYMENT
It was really exciting to see my first droplet come online
Sunday, October 6, 13
If you don’t care much
about the “managed” part
of managed hosting and
really want things to roar
like a bat out of hell...

HOSTING, BUT WHERE
The long search has come to an end
Sunday, October 6, 13
Once my “stealth project” goes live I
expect that within 2 years I will need
around 150 to 500 virtual servers.
(virtual servers of various capacities)
Digital Ocean has the absolute best
price point I’ve seen. And I’ve been
looking. Really looking.

STEALTH PROJECT
Not to mention, Digital Ocean has a nice evolving API to
manage all your “droplets”. Not as mature as Linode, though!
Sunday, October 6, 13
$20/mo shared hosting
v.s.
$5/mo Digital Ocean Droplet
Oakley Chamber of Commerce
WordPress site
(a heavy and NOT OPTIMIZED one!)

DEMO TIME ! DEMO TIME !
If this doesn’t convince you I don’t know what will
Sunday, October 6, 13
http://oakleychamber.com
http://oc.ignyter.com

TRY IT FOR YOURSELF
anyone with laptops here are encouraged to check it out
Sunday, October 6, 13
WAS THAT FAST
OR WAS THAT FAST?
Or is it just cool to know
that you can do it TOO!?

YES YOU CAN
Stop whining about the commandline and typing on the
keyboard, as if you don’t do that crap when you’re CSS’ing!!!
Sunday, October 6, 13
I can’t show you managed
hosting vs. Digital Ocean at
a $25-30/month vs. $5-10/
month price point...

BUT....
Sunday, October 6, 13
I will take any bet, for any amount of
serious money, that I can setup and
configure servers on Digital Ocean or
Linode that beat the living daylights
out of any managed hosting in terms
of performance.
And YOU can do it TOO!
So let’s not even talk about
shared hosting anymore, ok?
Sunday, October 6, 13
I know what I’m doing and...
may be biased.
I do, however, believe, that if you put
in some time to learn more than what
you copy & paste will serve you to be
even more valuable to your clients!

COPY AND PASTE
If you can’t do copy and paste then I’m wasting your time and I
am very sorry. If you can, however... new doors will open!
Sunday, October 6, 13
https://www.digitalocean.com/community
https://library.linode.com/
TUTORIALS, GUIDES, AND MORE

INSTALLING AND RUNNING
On how to install, configure, and run with all the things I
mentioned today, visit the libraries.
Sunday, October 6, 13
OPCODE CACHING
And now to explain what you’ve just seen
Sunday, October 6, 13
What your server does for EVERY page hit
on your site:
Read most (or all) of your PHP files/code
Interpret each line & “compile” it into what
the CPU understands
Execute the “compiled” code and render out the
page by sending it to the browser.

OPCODE CACHING
Yeah, uh, sure, what what does it DO?!
Sunday, October 6, 13
What your server does for EVERY page hit
on your site:
Read most (or all) of your PHP files/code
Interpret each line & “compile” it into what
the CPU understands
Execute the “compiled” code and render out the
page by sending it to the browser.

OPCODE CACHING
Yeah, uh, sure, what what does it DO?!
Sunday, October 6, 13
WITHOUT OPCODE CACHING
PHP

PARSE

PHP

APC
CACHE

COMPILE

EXECUTE

SEND

EXECUTE

SEND

WITH OPCODE CACHING

OPCODE CACHING
The simple explanation
Sunday, October 6, 13
APC
XCache
eAccelerator
Zend OpCache
NuSphere PHPExpress
IonCube Accelerator

OPCODE CACHING
Speeds up your site much more than “regular” file/data caching
Sunday, October 6, 13
Because APC is going to
be included in “PHP6”
But as we all know, there is no such thing as PHP6, right?
There is a book on PHP6.
But there is no Beta of PHP6.
There isn’t even an Alpha of PHP6.

BUT PHP 5.5 HAS OPCACHE
Performance between APC, XCache, etc. is all very similar
Sunday, October 6, 13
PHP APC
APC = Alternative PHP Cache
Sunday, October 6, 13
Without APC

With “vanilla” APC

Req. Per Sec : 85
Time Per Req. : 900ms
Conc. Time Per Req. : 20ms
Xfer Rate : 898 Kbytes/s

Req. Per Sec : 138.5
Time Per Req. : 476ms
Conc. Time Per Req. : 9.5ms
Xfer Rate : 1265 Kbytes/s

Great, but...
IS THAT ALL?

BENCHMARKING APC
Your site without APC sucks donkey balls
Sunday, October 6, 13
Without APC

With “vanilla” APC

Req. Per Sec : 85
Time Per Req. : 900ms
Conc. Time Per Req. : 20ms
Xfer Rate : 898 Kbytes/s

Req. Per Sec : 138.5
Time Per Req. : 476ms
Conc. Time Per Req. : 9.5ms
Xfer Rate : 1265 Kbytes/s

Now with apc.stat=off
Req. Per Sec : 317.4
Time Per Req. : 152.1ms
Conc. Time Per Req. : 3.1ms
Xfer Rate : 3985 Kbytes/s

BENCHMARKING APC
Your site with APC and apc.stat = off WILL FLY!
Sunday, October 6, 13
Only turn APC.STAT to OFF if:
Your PHP code on the server does not
change and you are willing to restart
the web server if it does.
WP or Plugin updates =
CHANGE OF PHP CODE

APC.STAT = OFF
THINK AND PLAN BEFORE YOU TURN IT OFF
Sunday, October 6, 13
# /etc/init.d/apache2 restart
It’s just one line. Maybe not exactly
the same as this one, though.
And it’s only for a few seconds.

RESTARTING? SO WHAT?
There are other ways to deal with this but those are for
another time when we get real deep into server stuff
Sunday, October 6, 13
Ensure your server has:
php-pear, php5-dev, make, apache2-prefork-dev

# pecl install apc
Then add the extension to your php.ini (or other)

extension=apc.so

INSTALLING APC
Because it might be different for your flavor of server I’m not
going into too much detail here, but it’s dead easy
Sunday, October 6, 13
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128M (or 1G, etc.)
apc.ttl=3600
apc.user_ttl=7200
apc.gc_ttl=3600
apc.max_file_size=1M
apc.stat=1 (or 0)

CONFIGURING APC
You should tweak it as much as needed
And there’s a lot more you can tweak in APC
Sunday, October 6, 13
With APC installed you can use PHP
function calls to...
Manage the APC cache
Interrogate the APC cache
Load/Dump Binary cache data
START OPTIMIZING YOUR CODE
Integrate it selectively in your plugins

WORTH KNOWING
APC will also extend PHP with new functions
Sunday, October 6, 13
APC Object Cache Backend
http://wordpress.org/plugins/apc/
Place the object-cache.php
in your wp-content directory.
Optionally you can also install the
BATCACHE plugin

APC WITH A WP PLUGIN
Your mileage may vary
Sunday, October 6, 13
Apache = Process Based
Nginx = Event Based

APACHE V.S. NGINX
Because you might get a lot of visitors... all at the same time!
Sunday, October 6, 13
Asynchronous
Asynchronous = Scalability
Fewer Server Resources
(i.e. much less memory)
Better for heavy load sites

A FEW ADVANTAGES
On sites with light traffic you will not see much difference in
performance between event vs. processed based servers
Sunday, October 6, 13
10.000 concurrent connections
and Nginx still uses only a few MB of
memory
Apache... 100’s of MB’s
And often will not even handle the load.

ALSO A COST DIFFERENCE
Part of the cost of virtual servers is the amount of memory that
is available. Disk space is not as important as memory.
Sunday, October 6, 13
Back in 2008...
8000 live traffic requests per second
Apache would have fallen over
and DIED

WORDPRESS.COM
Big servers and big sites prefer Nginx... and now you know why
Sunday, October 6, 13
15MB of RAM and
10% of CPU resources
Apache and a pound load balancer
would freak out at the 1000th
process, using 400+MB RAM and
“leaking” 20MB RAM per hour

GAME OVER
Big servers and big sites prefer Nginx... and now you know why
Sunday, October 6, 13
WP development is “intertwined”
with the Apache world.
Support is “limited but growing”.

http://codex.wordpress.org/Nginx
http://wiki.nginx.org/WordPress

WORDPRESS & NGINX
Not quite a match made in heaven
You’ll have to do some marriage counseling
Sunday, October 6, 13
Nginx has no conceptual notion of
this thing called an .htaccess file
http://wordpress.org/plugins/nginx-helper/

Search for Nginx related WP plugins

WORDPRESS & NGINX
WHERE THE HECK DID MY .HTACCESS FILE GO?!
Sunday, October 6, 13
Caching HTTP Reverse Proxy
Proxy Servers are not just “the thing you set in your browser”
Sunday, October 6, 13
BROWSER

BROWSER

PROXY
SERVER

VARNISH

WEBSITE

WEBSITE

With Varnish YOU control the caching
(because not everyone uses a proxy)

VARNISH
And it really is... really really, really, REALLY FAST!
Sunday, October 6, 13
Cache on Disk
Cache in Memory
Control through VCL
(Varnish Cache Language)
VARNISH
You control the proxy and you control the resources
Sunday, October 6, 13
VARNISH
PORT 80

APACHE OR NGINX
PORT 8080

http://mysite.com

http://mysite.com:8080

Varnish points to a “backend” server
which happens to be itself but with
the web server on a different port

VARNISH SAME SERVER
Change the web server port to something else because
Varnish should respond on port 80
Sunday, October 6, 13
VARNISH
PORT 80

APACHE OR NGINX
PORT 8080

http://mysite.com
http://somesite.com
http://wowy.com
http://admin.com

http://mysite.com:8080
http://wowy.com:8080
APACHE OR NGINX
PORT 8081
http://somesite.com:8081
http://admin.com:8081

VARNISH DIFFERENT SERVERS
You can do the setup in whatever way you like
Sunday, October 6, 13
# Drop any cookies sent to Wordpress.
sub vcl_recv {
! if (!(req.url ~ "wp-(login|admin)")) {
! ! unset req.http.cookie;
! }
}
# Drop any cookies Wordpress
# tries to send back to the client.
sub vcl_fetch {
! if (!(req.url ~ "wp-(login|admin)")) {
! ! unset beresp.http.set-cookie;
! }
}

WP AND VARNISH
BEWARE OF COOKIES
Sunday, October 6, 13
MEMCACHED
The name of the game is “DISTRIBUTED”
Sunday, October 6, 13
The “for dummies” version:
Make better use of memory
Cache data in memory on
other servers that aren’t
using it as much.

AND IT DOES WHAT?
It manages cache and memory... for more than one server
Sunday, October 6, 13
DISTRIBUTED, I SAID
The more the merrier
Sunday, October 6, 13
System interconnects on servers
(depending on how you plan and set
them up) can still get more
performance over TCP/IP and
memory than a local server faced
with only its limited resources.
More servers = more memcached

WORDPRESS.COM
Yes, wordpress.com uses memcached. As do Twitter, Flickr,
Wikipedia, Craigslist, YouTube, and many others
Sunday, October 6, 13
$mc = new Memcache;
$mc->connect(‘10.0.1.20’, 11211);
$data = “cache this!”;
$mc->set(‘mydata’, $data, false, 100);
$result = $mc->get(‘mydata’);

MEMCACHED PHP
When installed Memcached will provide you a lot of PHP
functionality to have full control over your caching
Sunday, October 6, 13
BATCACHE
http://wordpress.org/plugins/batcache/

Place the advanced-cache.php
in your wp-content directory

“MEMCACHED PLUGIN”
Your mileage may vary
Sunday, October 6, 13
Single Malt Scotch
Hi Stefan!

Bourbon
Hi Mitch!

Tequila
Hi Kelly!

Beer
Hi Andrei!

LIFE IN THE SLOW LANE
If all this server and site performance is getting to you! :-)
Sunday, October 6, 13
http://eastbaywp.com/
http://www.stefandidak.com

DOWNLOAD THE SLIDES
Because this MAY have gone WAY too FAST for you!
Sunday, October 6, 13
Digital Ocean
https://www.digitalocean.com/

Redis
http://redis.io/

Linode
https://www.linode.com/

Memcached
http://memcached.org/

Rackspace
http://www.rackspace.com/

WordPress Batcache
http://wordpress.org/plugins/batcache/

Amazon VPC
http://aws.amazon.com/vpc/

WordPress APC Object Backend
http://wordpress.org/plugins/apc/

APC
http://php.net/manual/en/book.apc.php
XCache
http://xcache.lighttpd.net/

And finally, a “real developer’s” home office
because everyone keeps asking... :-)
http://www.stefandidak.com/office/
http://www.flickr.com/photos/didak/sets/72157633152434208/

eAccelerator
http://eaccelerator.net/

http://www.flickr.com/photos/didak/sets/72157632343719954/

Zend OpCache/Optimizer/Platform
http://en.wikipedia.org/wiki/Zend_Technologies

http://www.flickr.com/photos/didak/sets/72157632244753177/

Nginx
http://nginx.org/
Varnish
https://www.varnish-cache.org/

THINGS MENTIONED
In case you want to go look stuff up for yourself
Sunday, October 6, 13
QUESTIONS
Because I’m sure there’ll be some!
Sunday, October 6, 13

More Related Content

PDF
High Performance WordPress
PPTX
HyperDB, MySQL Performance, & Flavors of MySQL
PDF
WAG the Blog
PDF
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
PDF
WordPress Performance & Scalability
PPT
WebSockets and Java
PDF
Levelling up your WordPress development workflow
PPTX
Word press workflows and gulp
High Performance WordPress
HyperDB, MySQL Performance, & Flavors of MySQL
WAG the Blog
Host and Boast: Best Practices for Magento Hosting | Imagine 2013 Technolog…
WordPress Performance & Scalability
WebSockets and Java
Levelling up your WordPress development workflow
Word press workflows and gulp

What's hot (20)

PPTX
Tutorial sederhana netbeans & xampp
KEY
Chef meetup presentation
PDF
Speed Up That Site! - a guide to caching plugins
PDF
Performance and optimization
PDF
Optimizing wp
PDF
Surviving Slashdot
PPTX
Introduction To Programming in GNU-LINUX
ODP
T3DD11 - Scaleable TYPO3 Hosting
PDF
Scaling PHP to 40 Million Uniques
PDF
Local development with vvv jon trujillo
PPTX
A crash course in scaling wordpress
PPT
Creating Local WordPress Installs
PDF
Road to cloud hero
PDF
Coffeescript: An Opinionated Introduction
PPS
Scalable Web Architectures - Common Patterns & Approaches
PDF
PHPDay 2013 - High Performance PHP
PDF
Save Time by Managing WordPress from the Command Line
KEY
Dev ops for developers
PDF
Leeward WordPress Meetup- Caching and Website Speed
PDF
Web Development Fundamentals
Tutorial sederhana netbeans & xampp
Chef meetup presentation
Speed Up That Site! - a guide to caching plugins
Performance and optimization
Optimizing wp
Surviving Slashdot
Introduction To Programming in GNU-LINUX
T3DD11 - Scaleable TYPO3 Hosting
Scaling PHP to 40 Million Uniques
Local development with vvv jon trujillo
A crash course in scaling wordpress
Creating Local WordPress Installs
Road to cloud hero
Coffeescript: An Opinionated Introduction
Scalable Web Architectures - Common Patterns & Approaches
PHPDay 2013 - High Performance PHP
Save Time by Managing WordPress from the Command Line
Dev ops for developers
Leeward WordPress Meetup- Caching and Website Speed
Web Development Fundamentals
Ad

Viewers also liked (8)

PPT
Wellington may 10
PPT
Unitech Mt Albert 28 april 2010
PPT
How to Tweet
PPT
Queenstown Nov 2010
DOCX
PPTX
What Developers Need Designers to Know about WordPress
PDF
Global Paediatric Studies–A CRO perspective
PDF
Real Developer Tools for WordPress by Stefan Didak
Wellington may 10
Unitech Mt Albert 28 april 2010
How to Tweet
Queenstown Nov 2010
What Developers Need Designers to Know about WordPress
Global Paediatric Studies–A CRO perspective
Real Developer Tools for WordPress by Stefan Didak
Ad

Similar to Making WordPress Fly (20)

PDF
Cache Rules Everything Around Me
PDF
Pgbr 2013 postgres on aws
PDF
Consideration for Building a Private Cloud
PDF
Hammering Responsive Web Design Into Shape
DOCX
Technology tips to ceo & architect
ODP
Award-winning technology: Oxid loves the query cache
PPT
Performance and Scalability
ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
ODP
DiUS Computing Lca Rails Final
PPT
Roy foubister (hosting high traffic sites on a tight budget)
PPS
Scalable Web Arch
PDF
Cors michael
PDF
HTTP cache @ PUG Rome 03-29-2011
PDF
Tadas Pivorius. Married to Cassandra
ODP
How we setup Rsync-powered Incremental Backups
KEY
Site Performance - From Pinto to Ferrari
PDF
Cache all the things #DCLondon
PPT
Triple Blitz Strike
PPTX
JS digest. July 2018
PDF
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
Cache Rules Everything Around Me
Pgbr 2013 postgres on aws
Consideration for Building a Private Cloud
Hammering Responsive Web Design Into Shape
Technology tips to ceo & architect
Award-winning technology: Oxid loves the query cache
Performance and Scalability
MNPHP Scalable Architecture 101 - Feb 3 2011
DiUS Computing Lca Rails Final
Roy foubister (hosting high traffic sites on a tight budget)
Scalable Web Arch
Cors michael
HTTP cache @ PUG Rome 03-29-2011
Tadas Pivorius. Married to Cassandra
How we setup Rsync-powered Incremental Backups
Site Performance - From Pinto to Ferrari
Cache all the things #DCLondon
Triple Blitz Strike
JS digest. July 2018
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014

More from East Bay WordPress Meetup (20)

PDF
How to Conduct an SEO Audit
PPTX
WordPress Membership Plugins: WP-Members
PPTX
WordPress Membership Plugins: MemberPress
PDF
How to Develop a Color Palette for Your Website with Amanada McCoy
PDF
Event Management Plugins for WordPress
PDF
Beyond Gravity Forms: Form Plugins for WordPress
PDF
Is Your (Client's) Website Ready for 2017?
PDF
Git Version Control for the Complete N00b by Adam LaBarge
PDF
Making WordPress Easier to Use
PDF
WordPress Comments (November Meetup)
PDF
Sallie Goetsch: Making the Events Calendar Sit Up and Beg
PDF
Rob La Gatta; Making the Events Calendar Sit Up and Beg
PDF
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
PDF
March 2015: Plugins Worth Paying For
PDF
Google Webmaster Tools for WordPress
PDF
Introduction to Google Analytics by Katherine Mancuso
PDF
iThemes Exchange: the New Kid on the WordPress E-Commerce Block
PDF
Running a WordPress Business--Some Numbers
PDF
Drag-and-drop WordPress Themes, featuring Themify Builder
PDF
Drag and-Drop WordPress Themes
How to Conduct an SEO Audit
WordPress Membership Plugins: WP-Members
WordPress Membership Plugins: MemberPress
How to Develop a Color Palette for Your Website with Amanada McCoy
Event Management Plugins for WordPress
Beyond Gravity Forms: Form Plugins for WordPress
Is Your (Client's) Website Ready for 2017?
Git Version Control for the Complete N00b by Adam LaBarge
Making WordPress Easier to Use
WordPress Comments (November Meetup)
Sallie Goetsch: Making the Events Calendar Sit Up and Beg
Rob La Gatta; Making the Events Calendar Sit Up and Beg
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
March 2015: Plugins Worth Paying For
Google Webmaster Tools for WordPress
Introduction to Google Analytics by Katherine Mancuso
iThemes Exchange: the New Kid on the WordPress E-Commerce Block
Running a WordPress Business--Some Numbers
Drag-and-drop WordPress Themes, featuring Themify Builder
Drag and-Drop WordPress Themes

Recently uploaded (20)

PDF
Getting Started with Data Integration: FME Form 101
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
Getting Started with Data Integration: FME Form 101
SOPHOS-XG Firewall Administrator PPT.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
TLE Review Electricity (Electricity).pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
1. Introduction to Computer Programming.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Programs and apps: productivity, graphics, security and other tools
A comparative analysis of optical character recognition models for extracting...
A comparative study of natural language inference in Swahili using monolingua...
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx

Making WordPress Fly

  • 1. EAST BAY WORDPRESS MEETUP HOW TO MAKE WP FLY... LIKE A BAT OUT OF HELL Sunday, October 6, 13
  • 2. EXPLAINING THE SECRETS BEHIND MANAGED HOSTING AND REALLY FAST WORDPRESS SITES THE ALTERNATIVE TITLE I could have renamed this presentation Sunday, October 6, 13
  • 4. The sound a WordPress site should make when your client is happy to pay you more because their site is so fast that it puts their competition to shame. TIME = MONEY Sunday, October 6, 13
  • 5. Caching provided by optimizing your site Caching through plugins Caching because of all of the above As you’ve already been shown today LEVELS OF CACHING all of those make a difference but... NOT ENOUGH Sunday, October 6, 13
  • 6. Don’t just optimize your site Optimize YOUR SERVER! and if you have none, build one! Optimize YOUR CODE TOO! LEVELS OF CACHING Everything I’m going to show today requires you to have full control and access to your server (VM, VPS, Cloud, etc.) Sunday, October 6, 13
  • 7. WordPress Caching Digital Ocean + DEMO OpCode Caching Apache v.s. Nginx Varnish Memcached WHAT I’LL BE COVERING Also known as the Tip of the Iceberg Sunday, October 6, 13
  • 8. WP CACHING OVERVIEW Everyone should know what levels of caching WP supports Sunday, October 6, 13
  • 9. Only lasts the duration of the request. After the request the run-time cache no longer exists. For example: the global $post and $wp_query variables WORDPRESS CACHING Run-Time Cache Sunday, October 6, 13
  • 10. WordPress has a “Transient Cache” API that allows you to store data in your MySQL DB. Ahum... Right... But it can still be useful... if used selectively WORDPRESS CACHING Transient Cache Sunday, October 6, 13
  • 11. Is usually persistent because it’s stored “somewhere”. Somewhere could be in memory through APC, Memcached, or Redis, but could also be in your MySQL DB or on disk. WORDPRESS CACHING Object Cache Sunday, October 6, 13
  • 12. Stores HTML data representing entire pages. This is one of the more typical caching schemes used by most plugins. Unfortunately, not so useful when you have highly dynamic pages where someone does not always get the same content (i.e. membership sites). WORDPRESS CACHING Page Cache - Stored on disk or in memory Sunday, October 6, 13
  • 13. I don’t like the term and it is no different from the Object Cache. Instead of storing entire HTML pages it stores parts of pages. I like to think of it as just another object because that’s what it is. WORDPRESS CACHING Fragment Cache Sunday, October 6, 13
  • 14. I prefer to have full control over my own online servers because I can have them be faster than managed hosting at a fraction of the cost. PERSONAL EXPERIENCE Managed Hosting, however optimized, is still designed to be a version of a “one size fits all” approach Sunday, October 6, 13
  • 15. GREAT(ER) PERFORMANCE & OK PRICES GREAT PERFORMANCE & COOL PRICES SLOW & EXPENSIVE Sunday, October 6, 13 NICE PERFORMANCE & CAN GET EXPENSIVE
  • 16. After running and testing my first “droplet” on Digital Ocean and after playing with some deployments on Linode I knew my shared hosting for 30+ domains would come to an end. A very WELCOME END! FIRST DEPLOYMENT It was really exciting to see my first droplet come online Sunday, October 6, 13
  • 17. If you don’t care much about the “managed” part of managed hosting and really want things to roar like a bat out of hell... HOSTING, BUT WHERE The long search has come to an end Sunday, October 6, 13
  • 18. Once my “stealth project” goes live I expect that within 2 years I will need around 150 to 500 virtual servers. (virtual servers of various capacities) Digital Ocean has the absolute best price point I’ve seen. And I’ve been looking. Really looking. STEALTH PROJECT Not to mention, Digital Ocean has a nice evolving API to manage all your “droplets”. Not as mature as Linode, though! Sunday, October 6, 13
  • 19. $20/mo shared hosting v.s. $5/mo Digital Ocean Droplet Oakley Chamber of Commerce WordPress site (a heavy and NOT OPTIMIZED one!) DEMO TIME ! DEMO TIME ! If this doesn’t convince you I don’t know what will Sunday, October 6, 13
  • 20. http://oakleychamber.com http://oc.ignyter.com TRY IT FOR YOURSELF anyone with laptops here are encouraged to check it out Sunday, October 6, 13
  • 21. WAS THAT FAST OR WAS THAT FAST? Or is it just cool to know that you can do it TOO!? YES YOU CAN Stop whining about the commandline and typing on the keyboard, as if you don’t do that crap when you’re CSS’ing!!! Sunday, October 6, 13
  • 22. I can’t show you managed hosting vs. Digital Ocean at a $25-30/month vs. $5-10/ month price point... BUT.... Sunday, October 6, 13
  • 23. I will take any bet, for any amount of serious money, that I can setup and configure servers on Digital Ocean or Linode that beat the living daylights out of any managed hosting in terms of performance. And YOU can do it TOO! So let’s not even talk about shared hosting anymore, ok? Sunday, October 6, 13
  • 24. I know what I’m doing and... may be biased. I do, however, believe, that if you put in some time to learn more than what you copy & paste will serve you to be even more valuable to your clients! COPY AND PASTE If you can’t do copy and paste then I’m wasting your time and I am very sorry. If you can, however... new doors will open! Sunday, October 6, 13
  • 25. https://www.digitalocean.com/community https://library.linode.com/ TUTORIALS, GUIDES, AND MORE INSTALLING AND RUNNING On how to install, configure, and run with all the things I mentioned today, visit the libraries. Sunday, October 6, 13
  • 26. OPCODE CACHING And now to explain what you’ve just seen Sunday, October 6, 13
  • 27. What your server does for EVERY page hit on your site: Read most (or all) of your PHP files/code Interpret each line & “compile” it into what the CPU understands Execute the “compiled” code and render out the page by sending it to the browser. OPCODE CACHING Yeah, uh, sure, what what does it DO?! Sunday, October 6, 13
  • 28. What your server does for EVERY page hit on your site: Read most (or all) of your PHP files/code Interpret each line & “compile” it into what the CPU understands Execute the “compiled” code and render out the page by sending it to the browser. OPCODE CACHING Yeah, uh, sure, what what does it DO?! Sunday, October 6, 13
  • 29. WITHOUT OPCODE CACHING PHP PARSE PHP APC CACHE COMPILE EXECUTE SEND EXECUTE SEND WITH OPCODE CACHING OPCODE CACHING The simple explanation Sunday, October 6, 13
  • 30. APC XCache eAccelerator Zend OpCache NuSphere PHPExpress IonCube Accelerator OPCODE CACHING Speeds up your site much more than “regular” file/data caching Sunday, October 6, 13
  • 31. Because APC is going to be included in “PHP6” But as we all know, there is no such thing as PHP6, right? There is a book on PHP6. But there is no Beta of PHP6. There isn’t even an Alpha of PHP6. BUT PHP 5.5 HAS OPCACHE Performance between APC, XCache, etc. is all very similar Sunday, October 6, 13
  • 32. PHP APC APC = Alternative PHP Cache Sunday, October 6, 13
  • 33. Without APC With “vanilla” APC Req. Per Sec : 85 Time Per Req. : 900ms Conc. Time Per Req. : 20ms Xfer Rate : 898 Kbytes/s Req. Per Sec : 138.5 Time Per Req. : 476ms Conc. Time Per Req. : 9.5ms Xfer Rate : 1265 Kbytes/s Great, but... IS THAT ALL? BENCHMARKING APC Your site without APC sucks donkey balls Sunday, October 6, 13
  • 34. Without APC With “vanilla” APC Req. Per Sec : 85 Time Per Req. : 900ms Conc. Time Per Req. : 20ms Xfer Rate : 898 Kbytes/s Req. Per Sec : 138.5 Time Per Req. : 476ms Conc. Time Per Req. : 9.5ms Xfer Rate : 1265 Kbytes/s Now with apc.stat=off Req. Per Sec : 317.4 Time Per Req. : 152.1ms Conc. Time Per Req. : 3.1ms Xfer Rate : 3985 Kbytes/s BENCHMARKING APC Your site with APC and apc.stat = off WILL FLY! Sunday, October 6, 13
  • 35. Only turn APC.STAT to OFF if: Your PHP code on the server does not change and you are willing to restart the web server if it does. WP or Plugin updates = CHANGE OF PHP CODE APC.STAT = OFF THINK AND PLAN BEFORE YOU TURN IT OFF Sunday, October 6, 13
  • 36. # /etc/init.d/apache2 restart It’s just one line. Maybe not exactly the same as this one, though. And it’s only for a few seconds. RESTARTING? SO WHAT? There are other ways to deal with this but those are for another time when we get real deep into server stuff Sunday, October 6, 13
  • 37. Ensure your server has: php-pear, php5-dev, make, apache2-prefork-dev # pecl install apc Then add the extension to your php.ini (or other) extension=apc.so INSTALLING APC Because it might be different for your flavor of server I’m not going into too much detail here, but it’s dead easy Sunday, October 6, 13
  • 38. apc.enabled=1 apc.shm_segments=1 apc.shm_size=128M (or 1G, etc.) apc.ttl=3600 apc.user_ttl=7200 apc.gc_ttl=3600 apc.max_file_size=1M apc.stat=1 (or 0) CONFIGURING APC You should tweak it as much as needed And there’s a lot more you can tweak in APC Sunday, October 6, 13
  • 39. With APC installed you can use PHP function calls to... Manage the APC cache Interrogate the APC cache Load/Dump Binary cache data START OPTIMIZING YOUR CODE Integrate it selectively in your plugins WORTH KNOWING APC will also extend PHP with new functions Sunday, October 6, 13
  • 40. APC Object Cache Backend http://wordpress.org/plugins/apc/ Place the object-cache.php in your wp-content directory. Optionally you can also install the BATCACHE plugin APC WITH A WP PLUGIN Your mileage may vary Sunday, October 6, 13
  • 41. Apache = Process Based Nginx = Event Based APACHE V.S. NGINX Because you might get a lot of visitors... all at the same time! Sunday, October 6, 13
  • 42. Asynchronous Asynchronous = Scalability Fewer Server Resources (i.e. much less memory) Better for heavy load sites A FEW ADVANTAGES On sites with light traffic you will not see much difference in performance between event vs. processed based servers Sunday, October 6, 13
  • 43. 10.000 concurrent connections and Nginx still uses only a few MB of memory Apache... 100’s of MB’s And often will not even handle the load. ALSO A COST DIFFERENCE Part of the cost of virtual servers is the amount of memory that is available. Disk space is not as important as memory. Sunday, October 6, 13
  • 44. Back in 2008... 8000 live traffic requests per second Apache would have fallen over and DIED WORDPRESS.COM Big servers and big sites prefer Nginx... and now you know why Sunday, October 6, 13
  • 45. 15MB of RAM and 10% of CPU resources Apache and a pound load balancer would freak out at the 1000th process, using 400+MB RAM and “leaking” 20MB RAM per hour GAME OVER Big servers and big sites prefer Nginx... and now you know why Sunday, October 6, 13
  • 46. WP development is “intertwined” with the Apache world. Support is “limited but growing”. http://codex.wordpress.org/Nginx http://wiki.nginx.org/WordPress WORDPRESS & NGINX Not quite a match made in heaven You’ll have to do some marriage counseling Sunday, October 6, 13
  • 47. Nginx has no conceptual notion of this thing called an .htaccess file http://wordpress.org/plugins/nginx-helper/ Search for Nginx related WP plugins WORDPRESS & NGINX WHERE THE HECK DID MY .HTACCESS FILE GO?! Sunday, October 6, 13
  • 48. Caching HTTP Reverse Proxy Proxy Servers are not just “the thing you set in your browser” Sunday, October 6, 13
  • 49. BROWSER BROWSER PROXY SERVER VARNISH WEBSITE WEBSITE With Varnish YOU control the caching (because not everyone uses a proxy) VARNISH And it really is... really really, really, REALLY FAST! Sunday, October 6, 13
  • 50. Cache on Disk Cache in Memory Control through VCL (Varnish Cache Language) VARNISH You control the proxy and you control the resources Sunday, October 6, 13
  • 51. VARNISH PORT 80 APACHE OR NGINX PORT 8080 http://mysite.com http://mysite.com:8080 Varnish points to a “backend” server which happens to be itself but with the web server on a different port VARNISH SAME SERVER Change the web server port to something else because Varnish should respond on port 80 Sunday, October 6, 13
  • 52. VARNISH PORT 80 APACHE OR NGINX PORT 8080 http://mysite.com http://somesite.com http://wowy.com http://admin.com http://mysite.com:8080 http://wowy.com:8080 APACHE OR NGINX PORT 8081 http://somesite.com:8081 http://admin.com:8081 VARNISH DIFFERENT SERVERS You can do the setup in whatever way you like Sunday, October 6, 13
  • 53. # Drop any cookies sent to Wordpress. sub vcl_recv { ! if (!(req.url ~ "wp-(login|admin)")) { ! ! unset req.http.cookie; ! } } # Drop any cookies Wordpress # tries to send back to the client. sub vcl_fetch { ! if (!(req.url ~ "wp-(login|admin)")) { ! ! unset beresp.http.set-cookie; ! } } WP AND VARNISH BEWARE OF COOKIES Sunday, October 6, 13
  • 54. MEMCACHED The name of the game is “DISTRIBUTED” Sunday, October 6, 13
  • 55. The “for dummies” version: Make better use of memory Cache data in memory on other servers that aren’t using it as much. AND IT DOES WHAT? It manages cache and memory... for more than one server Sunday, October 6, 13
  • 56. DISTRIBUTED, I SAID The more the merrier Sunday, October 6, 13
  • 57. System interconnects on servers (depending on how you plan and set them up) can still get more performance over TCP/IP and memory than a local server faced with only its limited resources. More servers = more memcached WORDPRESS.COM Yes, wordpress.com uses memcached. As do Twitter, Flickr, Wikipedia, Craigslist, YouTube, and many others Sunday, October 6, 13
  • 58. $mc = new Memcache; $mc->connect(‘10.0.1.20’, 11211); $data = “cache this!”; $mc->set(‘mydata’, $data, false, 100); $result = $mc->get(‘mydata’); MEMCACHED PHP When installed Memcached will provide you a lot of PHP functionality to have full control over your caching Sunday, October 6, 13
  • 59. BATCACHE http://wordpress.org/plugins/batcache/ Place the advanced-cache.php in your wp-content directory “MEMCACHED PLUGIN” Your mileage may vary Sunday, October 6, 13
  • 60. Single Malt Scotch Hi Stefan! Bourbon Hi Mitch! Tequila Hi Kelly! Beer Hi Andrei! LIFE IN THE SLOW LANE If all this server and site performance is getting to you! :-) Sunday, October 6, 13
  • 62. Digital Ocean https://www.digitalocean.com/ Redis http://redis.io/ Linode https://www.linode.com/ Memcached http://memcached.org/ Rackspace http://www.rackspace.com/ WordPress Batcache http://wordpress.org/plugins/batcache/ Amazon VPC http://aws.amazon.com/vpc/ WordPress APC Object Backend http://wordpress.org/plugins/apc/ APC http://php.net/manual/en/book.apc.php XCache http://xcache.lighttpd.net/ And finally, a “real developer’s” home office because everyone keeps asking... :-) http://www.stefandidak.com/office/ http://www.flickr.com/photos/didak/sets/72157633152434208/ eAccelerator http://eaccelerator.net/ http://www.flickr.com/photos/didak/sets/72157632343719954/ Zend OpCache/Optimizer/Platform http://en.wikipedia.org/wiki/Zend_Technologies http://www.flickr.com/photos/didak/sets/72157632244753177/ Nginx http://nginx.org/ Varnish https://www.varnish-cache.org/ THINGS MENTIONED In case you want to go look stuff up for yourself Sunday, October 6, 13
  • 63. QUESTIONS Because I’m sure there’ll be some! Sunday, October 6, 13