Web performance at WDCNZ

100
The Forgotten Art of Web Performance 14th July 2011 The Forgotten Art of Web Performance http://www.flickr.com/photos/mhzmaster/9659478 Friday, 15 July 2011

description

Forgotten Art of Web performance at WDCNZ

Transcript of Web performance at WDCNZ

Page 1: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

TheForgotten Art of Web Performance

http://www.flickr.com/photos/mhzmaster/965947834/

Friday, 15 July 2011

Page 2: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

I’m here to talk about making websites faster

Friday, 15 July 2011

Page 3: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

I’m here to talk about making websites faster

Friday, 15 July 2011

Page 4: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Web performance is about driving more traffic to your site

The forgotten art of Web Performance14th July 2011

http://www.flickr.com/photos/darrentunnicliff/3717976312/

Friday, 15 July 2011

Page 5: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Web performance is about “DevOps"

Friday, 15 July 2011

Page 6: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Hardware

O/S

Database

Application

Web server

Network

BACK END

Third party

Images

Javascript

CSS

HTML

FRONT END

Web Performance Optimisation Basics

Friday, 15 July 2011

Page 7: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Hardware

Web performance comes from combination of “back-end” and “front-end” optimisations

O/S

Database

Application

Web server

Network

BACK END

Third party

Images

Javascript

CSS

HTML

FRONT END

Friday, 15 July 2011

Page 8: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Hardware

O/S

Database

Application

Web server

Network

BACK END

Third party

Images

Javascript

CSS

HTML

FRONT END

95% of download time comes from “Front-end”

Friday, 15 July 2011

Page 9: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

You want to deliver content as fast as possible...

Hardware

O/S

Database

Application

Web server

Network

BACK END

Third party

Images

Javascript

CSS

HTML

FRONT END

Friday, 15 July 2011

Page 10: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Third party

Images

Javascript

CSS

HTML

FRONT END

You can maximise the requests you can

Hardware

O/S

Database

Application

Web server

Network

BACK END

Requests

Friday, 15 July 2011

Page 11: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Third party

Images

Javascript

CSS

HTML

FRONT END

by minimising request times of your stack

Hardware

O/S

Database

Application

Web server

Network

BACK END

Minimise

Friday, 15 July 2011

Page 12: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011The forgotten art of Web Performance14th July 2011

If Average request takes 50ms to serve and 200 “agents” => 4000 requests per second

Friday, 15 July 2011

Page 13: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

How do I fix?

The forgotten art of Web Performance14th July 2011

http://www.flickr.com/photos/lenore-m/2515800654/

Friday, 15 July 2011

Page 14: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Lots of tools to help you fix your site

The forgotten art of Web Performance14th July 2011

http://www.flickr.com/photos/lenore-m/2515800654/

Friday, 15 July 2011

Page 15: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

YSlow - 35 rules of Web performance

Friday, 15 July 2011

Page 16: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Pagespeed - 6 principles for speeding up

Friday, 15 July 2011

Page 17: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Aptimize.com

Friday, 15 July 2011

Page 18: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011The forgotten art of Web Performance14th July 2011

The difference web performance can make is hugehttp://www.flickr.com/photos/thebusybrain/2492945625/

Friday, 15 July 2011

Page 19: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011The forgotten art of Web Performance14th July 2011

It seems that some sites haven’t evolved

Friday, 15 July 2011

Page 20: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011The forgotten art of Web Performance14th July 2011

For web performance, some sites are stuck in the 90’s

http://www.dailystab.com/blog/wp-content/uploads/2007/12/spice-girls-vancouver-lg.jpg

Friday, 15 July 2011

Page 21: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Here’s a normal website

The forgotten art of Web Performance14th July 2011

Friday, 15 July 2011

Page 22: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

I see things a little differently

The forgotten art of Web Performance14th July 2011

Friday, 15 July 2011

Page 23: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

No HTTP Compression

Friday, 15 July 2011

Page 24: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Poor expiry settings

Friday, 15 July 2011

Page 25: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

No CSS / JS bundling

Friday, 15 July 2011

Page 26: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

No Spriting

Friday, 15 July 2011

Page 27: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Would you be proud of this ?

Friday, 15 July 2011

Page 28: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

1.2Mb, 133 requests, 21 JS files, 3 CSS files

The forgotten art of Web Performance14th July 2011

Friday, 15 July 2011

Page 29: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Why is WPO important?

Friday, 15 July 2011

Page 30: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Why is WPO important

“Slow websites are boring”

Slow websites are boring!

Friday, 15 July 2011

Page 31: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Customers are complaining about your site

Friday, 15 July 2011

Page 32: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Fast websites make more money

Friday, 15 July 2011

Page 33: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

“We see a direct correlation between the speed of our services and our bottom line.

Our customers seem inclined to spend a set time on our site per session – the more pages they

can view in that time, the more they see and buy, and the more we earn.”

John MacDonald - CTO Trade Me 2006

Time is Money

Friday, 15 July 2011

Page 34: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

WPO State of Nationhttp://www.flickr.com/photos/nznationalparty/4436793708/

Friday, 15 July 2011

Page 35: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Homepage hall of shame2011

160 sitesHome broadband

vs Office broadband

Friday, 15 July 2011

Page 36: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Key findings

Office BBandAve pageload time

6.01s

Home BBandAve pageload time

12.5s

Ave home page size

665K

Friday, 15 July 2011

Page 37: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Whoʼs the fastest1.17s Telecom

1.23s DOL

1.49s Snipesoft

1.58s Auckland Uni

1.59 Massey Uni

1.62s Zenbu

1.72s Geonet

1.73s School.nz

1.78s Maxx

1.59 Westpac

Friday, 15 July 2011

Page 38: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Whoʼs the S L O W E S T26.8s Skykiwi

20.9s The Standard

20.1s iStars

17.2s WhaleOil

16.4s NZ Yahoo

16.3s interest.co.nz

15.1s 3 News

15.1s The Big Idea

14.7s Readers Digest

14.3s Stuff

Friday, 15 July 2011

Page 39: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Data on Google docs

http://tinyurl.com/homepageHOS2011

Friday, 15 July 2011

Page 40: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Forgotten art of Web performancehttp://www.flickr.com/photos/23927132@N05/2500055549/

Friday, 15 July 2011

Page 41: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Once upon a time...

Friday, 15 July 2011

Page 42: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Internet speeds were crap

Friday, 15 July 2011

Page 43: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Had to learn to scale the hard wayhttp://www.flickr.com/photos/kitby/5414374130/

Friday, 15 July 2011

Page 44: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

4 principles to help you scale your

siteFriday, 15 July 2011

Page 45: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Rule 1) Dynamic vs Static

The forgotten art of Web Performance14th July 2011

Friday, 15 July 2011

Page 46: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

What is dynamic content?

Friday, 15 July 2011

Page 47: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Almost everything is static for a time

1 minute ?5 minutes ?

30 minutes ?Text

1 hour ?

Friday, 15 July 2011

Page 48: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

We used to pre-generate content

Friday, 15 July 2011

Page 49: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Web servers love static content

2000+ req / secvs

30 req / sec

Friday, 15 July 2011

Page 50: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

1) Pre-generate contenthttp://www.flickr.com/photos/aquariawintersoul/4162431443/The forgotten art of Web Performance

14th July 2011Friday, 15 July 2011

Page 51: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

2) Cache everythinghttp://www.flickr.com/photos/markusnl/5563657463/

Friday, 15 July 2011

Page 52: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Database views

Memcachehttp://memcached.org

Varnish / Squidhttp://www.varnish-cache.org/

2) Cache everything

Friday, 15 July 2011

Page 53: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

2) Cache everything

Friday, 15 July 2011

Page 54: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Google likes Varnish

Friday, 15 July 2011

Page 55: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

3) Watch out for 3rd party widgets

Friday, 15 July 2011

Page 56: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Local heroes: geonet.org.nz

Friday, 15 July 2011

Page 57: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Pages are static - server generates page on earthquake event

Friday, 15 July 2011

Page 58: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Built own CDN + plus lots of other stuff

Friday, 15 July 2011

Page 59: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Handles 12,000 req/sec at peak

Friday, 15 July 2011

Page 60: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Rule 2) User perception

http://www.flickr.com/photos/jasongillyon/243909248/

Friday, 15 July 2011

Page 61: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

We used to divide 50 row table into tables of 10 rows

The forgotten art of Web Performance14th July 2011

http://www.flickr.com/photos/silkroadcollection/4886903818/

Friday, 15 July 2011

Page 62: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

1) Front end techniques

Friday, 15 July 2011

Page 63: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Delay JS loading http://www.flickr.com/photos/sbisson/3852086117/

Friday, 15 July 2011

Page 64: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Load only what users can see

Friday, 15 July 2011

Page 65: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Who’s doing it right

Asynchronous JS loads content

Friday, 15 July 2011

Page 66: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Who’s doing it right

Google image search

Friday, 15 July 2011

Page 67: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Who’s doing it right

Twitter web client

Friday, 15 July 2011

Page 68: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Local heroes: geekzone.co.nz

Friday, 15 July 2011

Page 69: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Uses Aptimize WAX

Friday, 15 July 2011

Page 70: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Asychronous JS loading of ads, no revenue loss

Friday, 15 July 2011

Page 71: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Lots of performance optimisations

Friday, 15 July 2011

Page 72: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Site loads in just over 2 sec with lots of 3rd party stuff

Friday, 15 July 2011

Page 73: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Rule 3) Reduce requests

Friday, 15 July 2011

Page 74: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Browser round trip will kill you...

Friday, 15 July 2011

Page 75: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Looking at a site at DSL speed

Friday, 15 July 2011

Page 76: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Looking at a site at office speed

Friday, 15 July 2011

Page 77: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

When the earthquake strikes...

80+ images to serve

30ms local 270ms overseas

Up to 10 times more effort to serve content

Friday, 15 July 2011

Page 78: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Javascript and CSS Bundlinghttp://www.flickr.com/photos/ferguson666/3605271302/

Friday, 15 July 2011

Page 79: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Bundling tools

YUI Compressorhttp://developer.yahoo.com/yui/compressor/

Google Closurehttp://code.google.com/closure/

Every framework has tools

Friday, 15 July 2011

Page 80: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Make bundling part of your build processhttp://www.flickr.com/photos/hifumiyo/4021034029/

Friday, 15 July 2011

Page 81: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Image Spritinghttp://www.flickr.com/photos/roadsidepictures/1435060357/

Friday, 15 July 2011

Page 82: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

spriteme + smartsprites

Sprite mehttp://spriteme.org

Smart spriteshttp://csssprites.org/

Friday, 15 July 2011

Page 83: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

How many requests ???

Guide for number of page requests

< 20 Elite20-30 Excellent30-60 Average60-80 Below average80-100 Poor>100 My eyes are bleeding

Friday, 15 July 2011

Page 84: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Static image expiryhttp://www.flickr.com/photos/newtown_grafitti/5131604440/

The forgotten art of Web Performance14th July 2011

Friday, 15 July 2011

Page 85: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Who’s doing it right

Friday, 15 July 2011

Page 86: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Westpac - 20 requests - 1 request reload

Friday, 15 July 2011

Page 87: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Rule 4) Change defaults

http://www.flickr.com/photos/deadhorse/367716072/

Friday, 15 July 2011

Page 88: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Webserver settings

#### Server-Pool Size Regulation (MPM specific)##

# prefork MPM# StartServers: number of server processes to start# MinSpareServers: minimum number of server processes which are kept spare# MaxSpareServers: maximum number of server processes which are kept spare# MaxClients: maximum number of server processes allowed to start# MaxRequestsPerChild: maximum number of requests a server process serves<IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0</IfModule>

# worker MPM# StartServers: initial number of server processes to start# MaxClients: maximum number of simultaneous client connections# MinSpareThreads: minimum number of worker threads which are kept spare# MaxSpareThreads: maximum number of worker threads which are kept spare# ThreadsPerChild: constant number of worker threads in each server process# MaxRequestsPerChild: maximum number of requests a server process serves<IfModule mpm_worker_module> StartServers 2 MaxClients 150 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0</IfModule>

Friday, 15 July 2011

Page 89: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Webserver settings

Apache has 150 clients as default

You can change it!

Friday, 15 July 2011

Page 90: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Tweak settings

• Turn on compression• Increase of number of web clients• Set expiry for images

Switch to better webserver ;)

Friday, 15 July 2011

Page 91: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

True story - http server

Server browning out8Gb ram

Apache 250 clients running PHP4Gb Ram free

What to do ??Vendor says add

more servers

Friday, 15 July 2011

Page 92: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Database settings

my-small.cnf

# This is for a system with little memory (<= 64M) where MySQL is only used

my-medium.cnf

# This is for a system with little memory (32M - 64M) where MySQL plays

my-large.cnf

# This is for a large system with memory = 512M where the system runs mainly

my-huge.cnf

# This is for a large system with memory of 1G-2G where the system runs mainly

Friday, 15 July 2011

Page 93: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011The forgotten art of Web Performance14th July 2011

http://www.flickr.com/photos/jayneandd/4450623309/

Friday, 15 July 2011

Page 94: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Summary1) Use more static content

- Pre-generate- Cache everything- Minimise 3rd party widgets

2) Improve browser - Defer JS loading- Asychronous JS- Delay beyond the fold

Friday, 15 July 2011

Page 95: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Summary3) Minimise requests- Bundle JS + CSS files- Spriting- Set 2 year expiry for assets

4) Change defaults - Change defaults for Webserver and DB- Tweet to fit your server memory

Friday, 15 July 2011

Page 96: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Video

Final thought - Sites are around 550K

Friday, 15 July 2011

Page 97: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Video

Final thought - Sites are around 550K

Friday, 15 July 2011

Page 98: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Questions

Friday, 15 July 2011

Page 99: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Web testingGlobal Performance testing + Videos

www.webpagetest.org

Load testing software - (Linux) Siege + BombardBeen using for transaction testing of e-commerce buying

http://www.joedog.org/index/siege-home

Friday, 15 July 2011

Page 100: Web performance at WDCNZ

The Forgotten Art of Web Performance14th July 2011

Thank you

Friday, 15 July 2011