WORDPRESS

PERFORMANCE TUNING
Javier Arturo Rodríguez
@codehead
javier.rodriguez@puerto22.com
puerto:22

ABOUT ME

Certified System Administrator

Certified Software Architect

WordPress enthusiast

CTO at puerto22.com
javier.rodriguez@puerto22.com

@codehead

puerto:22

PERFORMANCE TUNING

puerto:22

TRADEOFFS

puerto:22

DIMENSIONS OF
PERFORMANCE

puerto:22

Fast

Easy
Inexpensive

puerto:22

Fast

Easy
Inexpensive

puerto:22

Fast

Easy
Inexpensive

puerto:22

Fast

Easy
Inexpensive

puerto:22

PICK ANY TWO
Fast

Easy
Inexpensive

puerto:22

MEASURE

puerto:22

OPTIMIZATION
Measure

!

"

Analyze

#
Change
puerto:22

OPTIMIZATION
Measure
Pick a metric

!

"
#
puerto:22

OPTIMIZATION
!

"

Analyze
Advance an
hypothesis
Plan a course
of action

#
puerto:22

OPTIMIZATION
!

"
#
Change

Act!
puerto:22

OPTIMIZATION
Measure
Get a new
measurement
of the same
metric

!

"
#
puerto:22

OPTIMIZATION
Measure

!

"

Analyze

#
Change
puerto:22

CLIENT VS SERVER

!

$

!

puerto:22

CLIENT VS SERVER
!

!

$

!
!

!

!

puerto:22

Time To First Byte

METRICS!

Client: Load time

Developer Tools, Yslow, PageSpeed, Pingdom

Server: Requests per second

ApacheBench, siege, httperf

puerto:22

APACHEBENCH
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking demo2.demoinc.com (be patient).....done
Server Software:
Server Hostname:
Server Port:

Apache
demo2.demoinc.com
80

Document Path:
Document Length:

/
10884 bytes

Concurrency Level:
Time taken for tests:
Complete requests:
Failed requests:
Total transferred:
HTML transferred:
Requests per second:
Time per request:
Time per request:
Transfer rate:

10
15.467 seconds
100
0
1114376 bytes
1088400 bytes
6.47 [#/sec] (mean)
1546.727 [ms] (mean)
154.673 [ms] (mean, across all concurrent requests)
70.36 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd]
Connect:
54
67 20.9
Processing:
555 1430 280.4
Waiting:
439 1314 267.0
Total:
615 1497 277.6

median
60
1466
1369
1528

max
196
1808
1644
1871

Percentage of the requests served within a certain time (ms)
50%
1528
66%
1621
75%
1680
80%
1736
90%
1796
95%
1843
98%
1871
99%
1871
100%
1871 (longest request)

puerto:22

SIEGE
** SIEGE 3.0.8
** Preparing 20 concurrent users for battle.
The server is now under siege..
done.
Transactions:
2000 hits
Availability:
100.00 %
Elapsed time:
59.53 secs
Data transferred:
6.73 MB
Response time:
0.01 secs
Transaction rate:
33.60 trans/sec
Throughput:
0.11 MB/sec
Concurrency:
0.19
Successful transactions:
2000
Failed transactions:
0
Longest transaction:
0.04
Shortest transaction:
0.00

puerto:22

HTTPERF
httperf --hog --timeout=5 --client=0/1 --server=demo2.demoinc.com --port=80 --uri=/
--rate=10 --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to
FD_SETSIZE
Maximum connect burst length: 1
Total: connections 100 requests 100 replies 100 test-duration 9.903 s
Connection
Connection
Connection
Connection

rate: 10.1 conn/s (99.0 ms/conn, <=1 concurrent connections)
time [ms]: min 2.2 avg 2.8 max 6.8 median 2.5 stddev 0.6
time [ms]: connect 0.7
length [replies/conn]: 1.000

Request rate: 10.1 req/s (99.0 ms/req)
Request size [B]: 77.0
Reply
Reply
Reply
Reply

rate [replies/s]: min 10.0 avg 10.0 max 10.0 stddev 0.0 (1 samples)
time [ms]: response 1.8 transfer 0.3
size [B]: header 266.0 content 10884.0 footer 0.0 (total 11150.0)
status: 1xx=0 2xx=100 3xx=0 4xx=0 5xx=0

CPU time [s]: user 3.54 system 6.27 (user 35.7% system 63.3% total 99.1%)
Net I/O: 110.7 KB/s (0.9*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

puerto:22

ASIDE: LOG

51.15.54.100 - - 

[02/Dec/2016:11:45:27 +0000] "GET / HTTP/1.1" 200 5076 "-" 

"Mozilla/5.0 (pc-x86_64-linux-gnu)" "-" "D=11724"

puerto:22

SPEED AND EFFICIENCY

speed: swiftness or rate of performance or action: velocity

efficiency: productivity without waste

https://www.merriam-webster.com/

puerto:22

AREAS OF OPPORTUNITY

Number of Plugins

Number/size of Assets

Database Queries

API Calls

puerto:22

https://premium.wpmudev.org/blog/essential-wordpress-plugins/

PLUGINS

Profile

Delete unused plugins

Eliminate redundancy

When in doubt, delete

puerto:22

PROFILE!

puerto:22

P³ (PLUGIN PERFORMANCE PROFILER)

puerto:22

XCACHE + CACHEGRIND

puerto:22

ASSETS

Concatenate

Minify

Compress

Make cache-friendly

Offload

puerto:22

puerto:22

puerto:22

DATABASE

Offload

Index

Cache

Objects

Queries

puerto:22

API CALLS

Theme optimization

Opcode Caching

puerto:22

APPROXIMATE
STATIC-PAGE SERVING

puerto:22

DON’T RE-GENERATE
WHAT YOU CAN CACHE

puerto:22

CACHING

varnish

memcached/redis

WP Super Cache

W3 Total Cache

puerto:22

CACHING

Improved serving time

Less server load

puerto:22

CACHING
WP
Database

puerto:22

CACHING
varnish

WP
Database

puerto:22

CACHING
WP
memcached
redis

Database

puerto:22

CACHING
W3 Total Cache

WP
Database

puerto:22

W3 TOTAL CACHE

Disk caching

Database caching

Object caching

CDN

puerto:22

DON’T SERVE ASSETS THAT
OTHERS ARE WILLING TO
SERVE FOR YOU

puerto:22

OFFLOADING

Content Distribution Networks

Edge Serving

Edge Caching

puerto:22

WP

puerto:22

IMG

IMG
WP
IMG

IMG
IMG

puerto:22

IMG

IMG
WP
IMG

IMG
IMG

puerto:22

WP

WP
WP
WP

WP
WP

puerto:22

OFFLOADING

Overcome single-host bottleneck

Less server load

Less bandwidth usage

puerto:22

OFFLOADING
HTML
CSS
JS
WOF
IMG

puerto:22

OFFLOADING
JS
CSS

HTML

WOF

IMG

puerto:22

OFFLOADING
JS
CSS

HTML

WOF

IMG

puerto:22

SCALING

puerto:22

SCALING STRATEGIES

Database spin-off

Scale Vertically

Scale Horizontally

puerto:22

DATABASE SPIN-OFF
WP
Database

puerto:22

DATABASE SPIN-OFF

WP

Database

puerto:22

SCALE VERTICALLY

puerto:22

SCALE VERTICALLY

puerto:22

SCALE HORIZONTALLY

puerto:22

SCALE HORIZONTALLY

puerto:22

SCALE HORIZONTALLY

WP

WP

WP

WP

puerto:22

SCALE HORIZONTALLY

WP

WP

WP

WP

Database

puerto:22

LOAD BALANCING
Load Balancer

WP

WP

WP

WP

Database

puerto:22

LOAD BALANCING
Load Balancer

WP

WP

WP

WP

Database

puerto:22

ELASTICITY
Load Balancer

WP

WP

Database

puerto:22

ELASTICITY
Load Balancer

WP

WP

WP

Database

puerto:22

ELASTICITY
Load Balancer

WP

WP

WP

WP

Database

puerto:22

FRONT-END CACHING
Load Balancer

Cache

WP

Cache

WP

WP

WP

Database

puerto:22

DATABASE

Cache

Index

Spin off

Replication

Partitioning

Check your slow_queries log!

puerto:22

REPLICATION
Load Balancer

WP

WP

Master

WP

WP

Replica

puerto:22

PARTITIONING
Load Balancer

WP

WP

Partition A

WP

WP

Partition B

puerto:22

PARTITIONING
Load Balancer

WP

WP

Partition A

WP

WP

Partition B

puerto:22

DATABASE

HyperDB

puerto:22

SERVER STACK
Theme

Plugins

WordPress
PHP RE
Web Server

Database

Operating System
Hardware

puerto:22

SERVER STACK
Theme

Plugins
W3 Total Cache
HyperDB

WordPress
APC
Xcache

PHP RE
Web Server

Database

varnish

Cache
Index
Spinoff
Replication
Partitioning

Operating System

Networking
Resource allocation

Hardware

SSD, IOPS
Scaling

puerto:22

DEFAULT STACK
Theme

Plugins

WordPress
Zend

PHP RE
mod_php

Apache

Web Server

Database

Operating System
Hardware

puerto:22

ALTERNATE STACK
Theme

Plugins

WordPress
HHVM

PHP RE
fastcgi

nginx

Web Server

Database

Operating System
Hardware

puerto:22

SEE ALSO

WordPress Optimization

https://codex.wordpress.org/WordPress_Optimization

puerto:22

SUMMARY

Performance Tuning is a process, not a product.

Measure. Profile.

Optimize your WordPress installation prior to scaling.

Look at the big picture.

Leverage Caching and Content Delivery Networks.

puerto:22

Q&A

puerto:22

THANK YOU!
Javier Arturo Rodríguez
@codehead
http://scribd.com/javierrgz/

puerto:22

Sign up to vote on this title
UsefulNot useful