SlideShare a Scribd company logo
Hello
This Slide Intentionally
      Left Blank
This One Too
Site Performance
from Pinto to Ferrari
                   Joseph Scott
       joseph@josephscott.org
         http://josephscott.org/
Find Me

http://josephscott.org/
joseph@josephscott.org
@josephscott
The Pinto
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/thomashawk/2466245846/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
http://www.flickr.com/photos/autohistorian/4439476737/
The Ferrari
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Steve Souders
http://stevesouders.com/
2007
2009
Why Did I Choose This Topic?
I Want My Site To Be Faster
I Want My Site To Be Faster

        Less Like A Pinto
I Want My Site To Be Faster

     More Like A Ferrari
How Fast Is It Now?
How Fast Is It Now?

Tools For Measuring
   Site Performance
Tools

webpagetest.org
pagespeed.googlelabs.com
Firefox & Firebug
Chrome/Safari & Dev Tools
HttpWatch
Where To Start?
Where To Start?

http://www.webpagetest.org/
webpagetest.org


Test Location
Browser
Connection Speed
Video
Browsers


      IE 8 still most commonly
   used browser (26.5% / 28.5%)



http://gs.statcounter.com/#browser_version-na-monthly-201106-201108-bar
Connection Speed



 FIOS 20Mbps
http://www.webpagetest.org/result/110827_KZ_1EBDB/1/details/
Which Part?
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
The Initial Request

Get the source
 for the page
The Initial Request

Get the source
                      0.113 seconds
 for the page
The Initial Request

DNS Lookup: 5 ms
Initial Connection: 47 ms
Time to First Byte: 57 ms
Content Download: 4 ms
Bytes In (downloaded): 9.6 KB
Bytes Out (uploaded): 0.4 KB
Requests Per Page


November 2010: 69

August 2011: 76


http://www.stevesouders.com/blog/2011/08/17/http-archive-nine-months/
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Thinking Clearly About
              Performance


http://carymillsap.blogspot.com/2010/02/thinking-
          clearly-about-performance.html
Average Lies
List A                    List B
0.924                     0.796
0.928                     0.798
0.954                     0.802
0.957                     0.823
0.961                     0.919
0.965                     0.977
0.972                     1.076
0.979                     1.216
0.987                     1.273
1.373                     1.320
         pg3, Exhibit 1
Aim For Consistent Performance
Site Performance - From Pinto to Ferrari
Know Your Limits

Calculate the theoretical best performance
               for your setup
Know Your Limits

Calculate the theoretical best performance
               for your setup


  What ever you actually end up with
       will be slower than that
Moving Up The Stack
The Stack




 Network
The Stack




Server Hardware

   Network
The Stack




Operating System

Server Hardware

    Network
The Stack


HTTP

       Operating System

       Server Hardware

           Network
The Stack


HTTP        PHP

       Operating System

       Server Hardware

           Network
The Stack


HTTP        PHP           MySQL

       Operating System

       Server Hardware

           Network
The Stack

          WordPress

HTTP        PHP           MySQL

       Operating System

       Server Hardware

           Network
The Stack

          WordPress

HTTP        PHP           MySQL

       Operating System

       Server Hardware

           Network
HTTP - The Web Server

Apache
  remove any modules you aren’t using
  turn off host name lookups
  turn off FollowSymLinks
  turn off .htaccess (if you can)
  turn on compression (mod_deflate)
  tweak MaxClients
HTTP - The Web Server

    Apache - mod_pagespeed

http://code.google.com/speed/page-speed/docs/module.html


  http://code.google.com/p/modpagespeed/
HTTP - The Web Server

Consider Alternatives


               Nginx
HTTP - The Web Server

    HTTP Compression

     Keep-alive support

Correctly Configured Caching
ETag Survey


HTTP/1.1 200 OK
ETag: "cd7ac991ff11"
ETag Survey

If-None-Match: "cd7ac991ff11"

HTTP/1.1 304 NOT MODIFIED
ETag Survey


ETags used by 136 of the top
      1,000 U.S. sites


 http://josephscott.org/archives/2011/09/etag-survey/
ETag Survey

Of the 136 sites using ETags:
  54 Worked Correctly (39.7%)
  11 Sort of Worked (8%)
  71 Broken/Useless (52.2%)
Understanding PHP
Understanding PHP

           Lifespan
.php



Read    Parse   Compile   Execute   Output
Understanding PHP

            Lifespan
.php



Read    Parse    Compile   Execute   Output


        Apache      /      mod_php
Understanding PHP
.php
           Lifespan
Read    Parse   Compile   Execute   Output


                FastCGI


                 Nginx
Reading




Open    Read     Close
Reading

Open            Read        Close


   Avoid   co$tly services like NFS
Parse

hello.php
            <?php
            echo "Hello, World!n"


Parse error: syntax error, unexpected $end,
expecting ',' or ';' in /tmp/hello.php on line 3
Tokens



              <?php echo
$tokens = token_get_all( '

  "Hello, World!";' );
foreach ( $tokens as $token ) {
    if ( is_array( $token ) ) {
        echo token_name( $token[0] ) . " ( {$token[2]} ) -
    {$token[1]}n";
    } else {
        echo "{$token}n";
    }
}
T_OPEN_TAG ( 1 ) - <?php
T_ECHO ( 1 ) - echo
T_WHITESPACE ( 1 ) -
T_CONSTANT_ENCAPSED_STRING ( 1 ) - "Hello,
  World!"
;
Compile
Branch analysis from position: 0
Return found
filename:     /tmp/hello.php
function name: (null)
number of ops: 3
compiled vars: none
line # op                              fetch         ext return operands
-------------------------------------------------------------------------------
   2 0 ECHO                                                       'Hello%2C+World%21%0A'
   3 1 RETURN                                                      1
        2* ZEND_HANDLE_EXCEPTION
Execute

Deceptively Simple Term

•Includes all sorts of activity
•Database / remote requests
Output


•PHP can buffer output
•Don’t forget about compression
Making PHP Faster
Making PHP Faster

.php



Read    Parse   Compile   Execute   Output
Making PHP Faster


.php



Read    APC
        Parse   Compile   Execute   Output
Making PHP Faster

.php



Read    APC
        Parse   Compile   Execute   Output




         opcode cache
PHP - opcode caching


              APC
requests per second - increased 4x
  time per request - decreased 4x
Use An Opcode Cache
              (APC)
Use An Opcode Cache
             (APC)!
APC == Free Money
APC == Free Money
PHP

use an opcode cache (APC)
use newer versions
don’t use on static files (unless you really need to)
consider output buffering
be careful with preg_* functions
profile your running code (Xdebug, VLD)
don’t re-invent native PHP functions, they are likely
faster than yours
The Stack

          WordPress

HTTP        PHP           MySQL

       Operating System

       Server Hardware

           Network
MySQL

use InnoDB table type (unless you have a
really good reason not to)
use the slow query log

use EXPLAIN on queries, learn
what the output means

double   triple check your indexes
learn about quirks
The Stack

          WordPress

HTTP        PHP           MySQL

       Operating System

       Server Hardware

           Network
Site Performance - From Pinto to Ferrari
Memcached

“Free & open source, high-performance,
distributed memory object caching
system”
  in memory only, won’t survive a reboot
  key/value data store


        http://memcached.org/
WordPress + Memcached

     Memcached Object Cache
       Persistent data store for WordPress objects
       Reduces the number of database queries



http://wordpress.org/extend/plugins/memcached/
I’m Batcache
WordPress + Memcached

   Batcache
      Persistent data store for rendered pages




http://wordpress.org/extend/plugins/batcache/
WordPress Caching - Alternatives

  WP Super Cache
    http://wordpress.org/extend/plugins/wp-super-cache/

  W3 Total Cache
    http://wordpress.org/extend/plugins/w3-total-cache/
But Wait, There’s More!
MySQL Replication

Master / Slave
  one way, asynchronous
  send writes to the master
  send reads to the slave
  supports multiple slaves, and chaining
WordPress + HyperDB

   Drop in replacement for default DB class
      distributed reads and writes
      partition data


http://wordpress.org/extend/plugins/hyperdb/
What Could This Look Like?
What Could This Look Like?



Net
         web & database
What Could This Look Like?



Net                db
         web
What Could This Look Like?


                   db
Net
         web


                memcached
What Could This Look Like?


                  db          db

Net
         web




               memcached   memcached
What Could This Look Like?


           web      db          db



  load     web
balancer



           web   memcached   memcached
Variations

slave just for backups
multiple data centers
task specific web servers
When Things Go Wrong
Hire an Amazing SysAdmin
Questions?
Find Me

http://josephscott.org/
joseph@josephscott.org
@josephscott

More Related Content

PDF
Apache and PHP: Why httpd.conf is your new BFF!
PDF
ApacheConNA 2015: What's new in Apache httpd 2.4
PPTX
Northeast PHP - High Performance PHP
PDF
Ansible : what's ansible & use case by REX
PDF
WordPress Home Server with Raspberry Pi
PPTX
Elastic stack
PDF
How to build a High Performance PSGI/Plack Server
PDF
php & performance
Apache and PHP: Why httpd.conf is your new BFF!
ApacheConNA 2015: What's new in Apache httpd 2.4
Northeast PHP - High Performance PHP
Ansible : what's ansible & use case by REX
WordPress Home Server with Raspberry Pi
Elastic stack
How to build a High Performance PSGI/Plack Server
php & performance

What's hot (20)

PDF
Scaling PHP to 40 Million Uniques
PDF
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
PDF
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
PDF
Developing cacheable PHP applications - PHPLimburgBE 2018
PDF
PHP & Performance
PDF
Developing cacheable PHP applications - Confoo 2018
PDF
Bottom to Top Stack Optimization - CICON2011
PDF
Symfony Performance
PPT
Roy foubister (hosting high traffic sites on a tight budget)
PDF
Scalable Django Architecture
PPTX
WordPress CLI in-depth
PDF
Manage WordPress with Awesome using wp cli
ODP
Caching and tuning fun for high scalability
PDF
How we use and deploy Varnish at Opera
PDF
Introduction to performance tuning perl web applications
ODP
Improving PHP Application Performance with APC
ODP
Remove php calls and scale your site like crazy !
PDF
PHPDay 2013 - High Performance PHP
PDF
Top Node.js Metrics to Watch
PPTX
PSGI and Plack from first principles
Scaling PHP to 40 Million Uniques
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Developing cacheable PHP applications - PHPLimburgBE 2018
PHP & Performance
Developing cacheable PHP applications - Confoo 2018
Bottom to Top Stack Optimization - CICON2011
Symfony Performance
Roy foubister (hosting high traffic sites on a tight budget)
Scalable Django Architecture
WordPress CLI in-depth
Manage WordPress with Awesome using wp cli
Caching and tuning fun for high scalability
How we use and deploy Varnish at Opera
Introduction to performance tuning perl web applications
Improving PHP Application Performance with APC
Remove php calls and scale your site like crazy !
PHPDay 2013 - High Performance PHP
Top Node.js Metrics to Watch
PSGI and Plack from first principles
Ad

Similar to Site Performance - From Pinto to Ferrari (20)

PDF
WordPress Performance & Scalability
PDF
Scaling WordPress
ODP
Caching and tuning fun for high scalability
PDF
Caching with Memcached and APC
PDF
Top ten-list
ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
ODP
Caching and tuning fun for high scalability
ODP
Caching and tuning fun for high scalability @ PHPTour
PDF
Bottom to Top Stack Optimization with LAMP
KEY
Introduction to NodeJS with LOLCats
ODP
Caching and tuning fun for high scalability @ FOSDEM 2012
PDF
Optimizing CakePHP 2.x Apps
PDF
Profiling PHP with Xdebug / Webgrind
PPT
Heavy Web Optimization: Backend
PPT
WE18_Performance_Up.ppt
PPT
Apache Traffic Server
ODP
Caching and tuning fun for high scalability @ phpBenelux 2011
ODP
Caching and tuning fun for high scalability @ FrOSCon 2011
PDF
Performance tuning with zend framework
PDF
Convert Your Dev Environment to a Docker Stack - PHP Tek 2025.pdf
WordPress Performance & Scalability
Scaling WordPress
Caching and tuning fun for high scalability
Caching with Memcached and APC
Top ten-list
MNPHP Scalable Architecture 101 - Feb 3 2011
Caching and tuning fun for high scalability
Caching and tuning fun for high scalability @ PHPTour
Bottom to Top Stack Optimization with LAMP
Introduction to NodeJS with LOLCats
Caching and tuning fun for high scalability @ FOSDEM 2012
Optimizing CakePHP 2.x Apps
Profiling PHP with Xdebug / Webgrind
Heavy Web Optimization: Backend
WE18_Performance_Up.ppt
Apache Traffic Server
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
Performance tuning with zend framework
Convert Your Dev Environment to a Docker Stack - PHP Tek 2025.pdf
Ad

More from Joseph Scott (7)

PDF
Site Testing with CasperJS
PDF
Python & FUSE
PDF
Improving Front End Performance
KEY
Anatomy of a PHP Request ( UTOSC 2010 )
PDF
WordPress APIs
PDF
WordPress Performance & Scalability
PDF
WordPress APIs
Site Testing with CasperJS
Python & FUSE
Improving Front End Performance
Anatomy of a PHP Request ( UTOSC 2010 )
WordPress APIs
WordPress Performance & Scalability
WordPress APIs

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation theory and applications.pdf
NewMind AI Monthly Chronicles - July 2025
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.

Site Performance - From Pinto to Ferrari

Editor's Notes