make drupal run fast increase page load speed

45
Make Drupal Run Fast increase page load speed www.prometsource.com

Upload: adam-mooney

Post on 27-Mar-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Make Drupal Run Fast increase page load speed

Make Drupal Run Fastincrease page load speed

www.prometsource.com

Page 2: Make Drupal Run Fast increase page load speed

2

http://www.flickr.com/photos/joconnell

Page 3: Make Drupal Run Fast increase page load speed

3

About Promet Source

Build websites – we built using open source tools on LAMP stack, specializing in Drupal development www.prometsource.com

Drupal Websites for Associations – FREE websites?? Maybe. Ask me. www.isupportdigital.com

Managed hosting in our Chicago Data center

History Founded in 2003

WHQ in Chicago, but mostly virtual

Customers

Page 4: Make Drupal Run Fast increase page load speed

4

Who is this guy?

Page 5: Make Drupal Run Fast increase page load speed

5

More about me – my beatifull & supportive wife

Page 6: Make Drupal Run Fast increase page load speed

6

More about me – shichon.blogspot.com

Page 7: Make Drupal Run Fast increase page load speed

7

What is page speed? And what is this presentation about?

What is page load speed?

Tools used to measure performance of your pages and site

Six Key Improvements to make Drupal "run fast" Performance Module settings and how they work

Caching - biggest gainer and how to implement Boost

Other quick hits: off loading search, tweaking settings & why running crons is important

Ask your host about APC and how to make sure its set up correctly

Dare we look at the database? Easy changes that will help a lot!

Page 8: Make Drupal Run Fast increase page load speed

8

Other related best practices

Monitoring Best practices - what to set up to make sure you know what is going on with your server

What if you get slashdoted? Recommendation on how to quickly take cover from a rhino.

Page 9: Make Drupal Run Fast increase page load speed

9

Why care about performance?

Google announced earlier this month:

We encourage you to start looking at your site’s speed— not only to improve your ranking in search engines, but also to improve everyone’s experience on the Internet.

Page 10: Make Drupal Run Fast increase page load speed

10

Definitions

Front End Performance Improvement – “In sampling the top ten U.S. websites, all but one spend less than 20% of the total response time getting the HTML document. The other 80+% of the time is spent dealing with what's in the HTML document, namely, the front-end. That's why the key to faster web sites is to focus on improving front-end performance. “**

Back End Performance Improvement – Server related to increase time to First Byte

Performance – How fast does the page load

Scalability - The ability for a distributed system to easily expand and contract its resource pool to accommodate heavier or lighter loads.

High Availablity

Page 11: Make Drupal Run Fast increase page load speed

11

Performance and Scalability

How fast do I get my page

… and now when im not the only one?

Creative Commons Imageshttp://www.flickr.com/photos/joiseyshowaa/http://www.flickr.com/photos/matt512/

Page 12: Make Drupal Run Fast increase page load speed

12

Front End vs. Back End

In sampling the top ten U.S. websites, all but one spend less than 20% of the total response time getting the HTML document. The other 80+% of the time is spent dealing with what's in the HTML document, namely, the front-end. That's why the key to faster web sites is to focus on improving front-end performance.

Page 13: Make Drupal Run Fast increase page load speed

13

Waterfall diagrams

Start - when browser sends request to server

Connect – when server acknowledges the request

First Byte – take it takes the server to render the page and send the first byte of the HTML

Last Byte – time it takes to transform the data

Page 14: Make Drupal Run Fast increase page load speed

14

Tools

Yslow for firebug http://developer.yahoo.com/yslow/

Page Speed - firebug http://code.Google.com/speed/articles/

Web Page Test http://www.webpagetest.org

Apache Bench http://httpd.apache.org/docs/2.0/programs/ab.html

JMeter http://jakarta.apache.org/jmeter/

Devel http://drupal.org/project/devel

Speed Tracer – chrome http://code.Google.com/webtoolkit/speedtracer

http://www.flickr.com/photos/bike/

Page 15: Make Drupal Run Fast increase page load speed

15

Yslow

•Steve Souders, while he was Chief Performance at Yahoo! Created YSLOW and best practices

•Firefox firebug plug in

•Grades your site based on yahoo best practices

•Scores – higher is better

Page 16: Make Drupal Run Fast increase page load speed

16

Page Speed

Steve Souders is now at Google

Google

Recommendations based on Google best practices

Page 17: Make Drupal Run Fast increase page load speed

17

Web Page Test (www.webpagetest.org)

Page 18: Make Drupal Run Fast increase page load speed

18

Page 19: Make Drupal Run Fast increase page load speed

19

Jmeter – Java based load testing tool

Page 20: Make Drupal Run Fast increase page load speed

20

Apache Bench

Very simple “It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.”

Ab –n # -c # http://[site]/

Page 21: Make Drupal Run Fast increase page load speed

21

Devel – great but check views stats separately

Page 22: Make Drupal Run Fast increase page load speed

22

http://www.flickr.com/people/13809318@N00

Page 23: Make Drupal Run Fast increase page load speed

23

Six Key Improvements to make Drupal “run fast”

On Site, on page changes (use Yslow and Page speed)

Performance Module settings and how they work

Caching – biggest gainer and how to implement Boost

Other quick hits: off loading search, tweaking settings & why running crons is important

Ask your host about APC and how to make sure its set up correctly

Dare we look at the database? Easy changes that will help a lot!

Performance improvements are implemented at many levels, are iterative

Change, test, analyze, repeat

Page 24: Make Drupal Run Fast increase page load speed

24

On Site, on page changes (use Yslow and Page speed)

Make Fewer HTTP requests

Use a CDN

Add Expires headers

Compress components with gzip deflate

Put CSS at top

Put JavaScript at Bottom

Configure entity tags (ETags)

Use cookie-free domains

Page 25: Make Drupal Run Fast increase page load speed

25

On Site, on page changes (use Yslow and Page speed) – Make fewer HTTP requests

Problem: Make fewer HTTP requests 80% of the end-user response time is spent on the front-end. Most of this

time is tied up in downloading all the components in the page: images, stylesheets, scripts, Flash, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages.

Drupal Solution Performance module – turn on Bandwidth optimizations for CSS and

Javascript files

Manual CSS sprite generator

Page 26: Make Drupal Run Fast increase page load speed

26

On Site, on page changes (use Yslow and Page speed) - With lots of objects – serve objects from multiple domains

Serve objects from multiple domains

There is trade off between dns look ups and parallel downloads

Browsers do matter (www.browserscope.com)

Page 27: Make Drupal Run Fast increase page load speed

27

On Site, on page changes (use Yslow and Page speed) - Use a CDN

CDN brings your content closer to the edge of the network, much faster response and download time

Drupal Modules:

http://drupal.org/project/simplecdn

http://drupal.org/project/cdn byWim Leers, needs a cron to runa fileconveyor

Media Mover

Page 28: Make Drupal Run Fast increase page load speed

28

http://www.flickr.com/photos/vincepal/

Page 29: Make Drupal Run Fast increase page load speed

29

Don’t let your traffic get to the DB – it wants to kill it!

Your Data center

Page 30: Make Drupal Run Fast increase page load speed

30

Performance Module Settings and how they work

Page 31: Make Drupal Run Fast increase page load speed

31

Apache tuning for Drupal

Extend mod_expires setting (make sure its on) in drupal .htaccess

Compress content before sending it

Apache deflate_module

Solution nginx – gzip module

.htaccess move to httpd.conf eliminates Apache parse and search on every load

Browser

•Cache

Page 32: Make Drupal Run Fast increase page load speed

32

Caching – reverse proxy

Caching - Very high performance gain

Advanced Step: Squid/Varnish (http://drupal.org/node/91813 )

Very high performance gain

Sidesteps web servers, may be implemented on separate servers

Reverse Proxy

•Cached Content

Page 33: Make Drupal Run Fast increase page load speed

33

Cache – Cache Router

Uses fastpath setting, bypassing default cache use

Enables different caching options

Faster because it by-passes database

Further configuration is necessary

Application Server

•APC•Memcache•Boost•Performance Module **

Page 34: Make Drupal Run Fast increase page load speed

34

Cache – Memcache module

Very simple caching mechanism – uses pair values stored in memory

Very fast

Using memcache by-passes the database caching

Is scalable and distrubuted

May live on other servers

Application Server

•APC•Memcache•Boost•Performance Module **

Page 35: Make Drupal Run Fast increase page load speed

35

Caching using Boost

Extension of Performance module

Instead of caching results in tables, stores them in files bypassing PHP and MySQL

Limited to anonymous visitors – so good for slashdot but not for sites with high number of authenticated visitors

How it works:Uses apache mod_rewrite directives in .htacess to check if GET

Logged in cookie does not exist

HTML file cached on fiilesystem

Application Server

•APC•Memcache•Boost•Performance Module **

Page 36: Make Drupal Run Fast increase page load speed

36

Boost Logic

http://drupal.org/files/images/Boost.preview.png

Page 37: Make Drupal Run Fast increase page load speed

37

Back End – PHP Accelerator

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code.

APC caching PHP code in a compiled state

Needs to be looked at after installation for proper configuration, but generally a big performance boost

Xcache and eacceletarotor are other options

Application Server

•APC•Memcache•Boost•Performance Module **

Page 38: Make Drupal Run Fast increase page load speed

38

MySQL caching

Enable MySQL Query Cache & give it memory

Index Slow queries that run often

Log-slow-queries

Use explain

Index indicies used

Some configuration considerations

InnoDB Buffer Pool ++

Key_buffer is important for temp tables

Core Search Runs Better on MyISAM (but don’t use core search)

MySQL

•MySQL caching

Page 39: Make Drupal Run Fast increase page load speed

39

Back End

MySQL is core of Drupal

MySQL tuning is important but may performance gain may not be as great as that of caching or front end

Always run and check slow query log often /Prune Drupal cache tables on busy sites

Database Performance/MySQL

Convert Tables to InnoDB Row level locking, less problematic on inserts than MyISAM

Advantages debated, but Drupal 7 install will be on InnoDB

Page 40: Make Drupal Run Fast increase page load speed

40

http://www.flickr.com/photos/howardlake

Page 41: Make Drupal Run Fast increase page load speed

41

Other quick Hits: off loading search, tweaking settings & why running crons is important - search

Search is resource intensive

Consider moving to Apache Solr or using Google Search free or Google Custom Search Engine Especially if converting tables to

innoDB

Page 42: Make Drupal Run Fast increase page load speed

42

Drupal settings for performance improvement

Always run cron

Set minimum cache lifetime to 0 and increase garbage collector run frequency for busy sites Settings.php:

Session.gc_maxlifetime

Session.cache_expire

Write watchdog entries to syslog instead of db table

Page 43: Make Drupal Run Fast increase page load speed

43

Monitoring Tools – Must have in server tuning

Trend spotting You can not fix back end problems if you do not know what they are

Capacity & Load Review impact of changes

Analyze Trends

Failure & Uptime Nagios

3rd party tools

Page 44: Make Drupal Run Fast increase page load speed

44

What if you get slashdotted?

RUN! PANIC!

Page 45: Make Drupal Run Fast increase page load speed

[email protected]

Blog: www.linuxsysadminblog.com

Site: www.prometsource.com

Questions ?