SlideShare uma empresa Scribd logo
1 de 81
Web Performance, Scalability, and Testing Techniques Boston PHP Meetup Group – April 2011 Jonathan Klein jklein@csnstores.com  @jonathanklein
What We’ll Cover Why Listen to Me? Why Performance Matters Measuring Server Side Performance Speeding up the Server Frontend Optimization Measuring Full Page Load Time Homework
What We’ll Cover Why Listen to Me? Why Performance Matters Measuring Server Side Performance Speeding up the Server Frontend Optimization Measuring Full Page Load Time Homework  Fun Performance Adventure!
Introduction Senior Software Engineer/Performance Guy at CSN Stores Organizer of the Boston Web Performance Meetup Group CSN Stores Stats: ~1400 requests/sec for static content ~400 requests/sec for dynamic content ~10 million unique visitors per month On a typical Monday we serve 75,000,000 static files
Currently converting all store code to PHP Windows Server  FreeBSD IIS  Lighttpd ~100,000 lines of ASP Classic  ~50,000 lines of PHP code ~5 weeks away from launch
Why Do We Care about Performance? A Faster Website Will Make You More Money
Firefox Firefox reduced the load time of their download page by 2.2 seconds Downloads went up 15.4% This could drive 60 MILLION yearly downloads
Google Injected a 400ms delay into search 0.44% fewer searches/user 0.76% after 6 weeks After delay was removed, 0.21% fewer searches
Yahoo! 400ms delay 5-9% drop in full-page traffic
Direct Relationship Between Speed and Dollars http://www.phpied.com/the-performance-business-pitch/
Server Side Monitoring Lots of Options: Paid: Coradiant dynaTrace Correlsense http://www.real-user-monitoring.com/ - Free Version Free: Access Logs Nagios Ganglia Hosted WebPagetest Selenium/dynaTrace Ajax Edition
Server Side Monitoring <?php $start = microtime(true); …script content… $end  = microtime(true); do_stuff(‘Description’, $end - $start); ?>
WTH is do_stuff()? do_stuff() can do one of: Log to a database (not ideal) Write to a text file (eww) Make a StatsD call over UDP (good) -http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
StatsD/Graphite
Be Careful What You Watch Averages can be misleading Better to look at percentiles
What Does a Scalability Problem Look Like?
What Does a Scalability Problem Look Like?
What Does a Scalability Problem Look Like?
Ahh, much better!
What can you do? Start with the Database Run a database trace  Filter: Queries > 50ms Filter: Reads > 1000 Start with the worst ones and optimize
Okay, I’ll “Optimize” Look at execution plan Remove calls to remote servers
Database Optimizations Reduce Joins Select * from  Select Foo, Bar, Baz from… Minimize/consolidate subqueries Add indexes where needed We added one index:  Procedure dropped from 3.5 sec & 4500 reads to .06 sec and 130 reads! Be careful with where clauses (don’t calculate stuff in them)
Example SELECT id, name, salary FROM employee WHERE salary < 25000;  NOT SELECT id, name, salary FROM employee WHERE salary + 10000 < 35000;
Example SELECT id, name, salary FROM employee WHERE salary < 25000;  NOT SELECT id, name, salary FROM employee WHERE salary + 10000 < 35000;
Caching The Fastest DB Query is the One That’s Never Made
Memcached Caching layer between database and webserver Can hold PHP objects and arrays
Memcached $m = new Memcached(); $m->pconnect(‘1.2.3.4', 11211); $m->set(‘foo’, $bar, 600); $baz = $m->get(‘foo’);
PHP Optimizations
Install APC APC – Alternative PHP Cache Opcode Cache User Cache Awesome!
Opcode cache
User Cache <?php$bar = 'BAR';apc_store('foo', $bar);var_dump(apc_fetch('foo'));?>  Outputs… string(3) "BAR"
PHP Code Optimizations Set the max loop value before the loop: $max = count($rows); for ($i = 0; $i < $max; $i++) {   	echo $i; } require_once() is slow Minimize use of define() Yes, single quotes are slightly faster than double quotes
PHP Code Optimizations Could go on and on… http://www.wmtips.com/php/tips-optimizing-php-code.htm Minimal returns Find the hotspots in your application and fix them
Example… Homepage takes 5 seconds to load Optimize PHP…  Reduce PHP execution time by 50%! But wait!  PHP execution was only taking 100ms Saves you 50ms in load time 1% of total page load
HipHop for PHP Built by Facebook and Open Sourced Compiles PHP into C++ Currently supports PHP 5.2 http://developers.facebook.com/blog/post/358/ https://github.com/facebook/hiphop-php
Webserver Considerations
Webserver Optimizations Pick the right one Lighttpd/Nginx instead of Apache Designed to solve the C10K problem Lighttpd Used By: Youtube Wikipedia Meebo
Lighttpd Benefits Event driven model: “Unlike traditional servers, Nginx doesn't rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.” ,[object Object],FastCGI+ spawn-fcgi PHP Process Management Many child processes – scale out application tier.
If you are stuck on Apache… mod_deflate Gzips content for faster transfer times mod_pagespeed Automatic performance improvements KeepAlives on Server won’t create a new connection for every resource
Load Testing
JMeter
JMeter
JMeter
Frontend Optimization
Client side Optimization is Critical 80-90% of load time takes place on the client For mobile   97%
Best Practices Reduce HTTP Requests Combine CSS, JS Use image sprites .classname{      background: url(sprite.png) no-repeat 0 -432px; }
Best Practices Minify CSS/JS Strip comments and whitespace Automate this – YUI Compressor http://developer.yahoo.com/yui/compressor/ Gzip all text HTML CSS JS Optimize Images…
Image Optimization For graphics use PNG8 (256 color limitation) No more .gif (unless animated) JPEGs can be saved at lower quality (75%-80%) Smush all images
Smush Your Images!  - smushit.com
JPEG Quality 100% 80% 182 KB 48 KB
Measuring Frontend Performance
How Do You Measure Load Time? Google Webmaster Tools WebPagetest (www.webpagetest.org) Yottaa.com Firebug YSlow PageSpeed Dynatrace Ajax Edition
CDN – Content Delivery Network
Lots of Options Amazon CloudFront MaxCDN Limelight Level3 Akamai Cotendo
Expires Headers Set a far future date on static resources CSS/JS/Images Release new version by changing the filename Benefits repeat visitors and repeat page views
Google Page Speed
Firebug Net Panel
Webmaster tools
Webmaster tools
Resources http://www.webperformancecentral.com/wiki/WebPagetest/Optimization_Help http://developer.yahoo.com/performance/ http://code.google.com/speed/ High Performance Websites  (Book) Even Faster Websites (Book)
Conclusion “Speed is the most important feature. If your application is slow, people won’t use it. I see this more with mainstream users than I do with power users...If something is slow, they’re just gone.” 	- Fred Wilson (10 Golden Principles of Web Apps)
Conclusion “Speed is the most important feature. If your application is slow, people won’t use it. I see this more with mainstream users than I do with power users...If something is slow, they’re just gone.” 	- Fred Wilson (10 Golden Principles of Web Apps)
?> We’re Hiring! www.csnstores.com/careers Get In Touch: www.meetup.com/Web-Performance-Boston/ jklein@csnstores.com @jonathanklein

Mais conteúdo relacionado

Mais procurados

Odoo - Open Source CMS: A performance comparision
Odoo - Open Source CMS: A performance comparisionOdoo - Open Source CMS: A performance comparision
Odoo - Open Source CMS: A performance comparisionOdoo
 
Prioritize your critical css and images to render your site fast velocity ny...
Prioritize your critical css and images to render your site fast  velocity ny...Prioritize your critical css and images to render your site fast  velocity ny...
Prioritize your critical css and images to render your site fast velocity ny...Jan-Willem Maessen
 
How to make your site 5 times faster in 10 minutes
How to make your site 5 times faster in 10 minutesHow to make your site 5 times faster in 10 minutes
How to make your site 5 times faster in 10 minutesGal Baras
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notesPerrin Harkins
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontendtkramar
 
Fotis alexandrou scalability on php - media camp 2010
Fotis alexandrou   scalability on php - media camp 2010Fotis alexandrou   scalability on php - media camp 2010
Fotis alexandrou scalability on php - media camp 2010Fotis Alexandrou
 
Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniquestakinbo
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
Web Performance: 3 Stages to Success
Web Performance: 3 Stages to SuccessWeb Performance: 3 Stages to Success
Web Performance: 3 Stages to SuccessAustin Gil
 
Measuring Web Performance
Measuring Web Performance Measuring Web Performance
Measuring Web Performance Dave Olsen
 
Background Processing - PyCon MY 2015
Background Processing - PyCon MY 2015Background Processing - PyCon MY 2015
Background Processing - PyCon MY 2015Kok Hoor Chew
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...John McCaffrey
 
PHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHPPHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHPJonathan Klein
 
Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Dave Olsen
 

Mais procurados (20)

Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
Ui perf
Ui perfUi perf
Ui perf
 
Odoo - Open Source CMS: A performance comparision
Odoo - Open Source CMS: A performance comparisionOdoo - Open Source CMS: A performance comparision
Odoo - Open Source CMS: A performance comparision
 
Prioritize your critical css and images to render your site fast velocity ny...
Prioritize your critical css and images to render your site fast  velocity ny...Prioritize your critical css and images to render your site fast  velocity ny...
Prioritize your critical css and images to render your site fast velocity ny...
 
Caching 101
Caching 101Caching 101
Caching 101
 
How to make your site 5 times faster in 10 minutes
How to make your site 5 times faster in 10 minutesHow to make your site 5 times faster in 10 minutes
How to make your site 5 times faster in 10 minutes
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
 
Fotis alexandrou scalability on php - media camp 2010
Fotis alexandrou   scalability on php - media camp 2010Fotis alexandrou   scalability on php - media camp 2010
Fotis alexandrou scalability on php - media camp 2010
 
Performance engineering
Performance engineeringPerformance engineering
Performance engineering
 
Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
HTTP Basics Demo
HTTP Basics DemoHTTP Basics Demo
HTTP Basics Demo
 
Web Performance: 3 Stages to Success
Web Performance: 3 Stages to SuccessWeb Performance: 3 Stages to Success
Web Performance: 3 Stages to Success
 
Measuring Web Performance
Measuring Web Performance Measuring Web Performance
Measuring Web Performance
 
Background Processing - PyCon MY 2015
Background Processing - PyCon MY 2015Background Processing - PyCon MY 2015
Background Processing - PyCon MY 2015
 
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
Ruby on Rails Performance Tuning. Make it faster, make it better (WindyCityRa...
 
Fluent 2012 v2
Fluent 2012   v2Fluent 2012   v2
Fluent 2012 v2
 
PHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHPPHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHP
 
Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)Optimizing web performance (Fronteers edition)
Optimizing web performance (Fronteers edition)
 

Destaque

Webpage Caches - the big picture (WordPress too)
Webpage Caches - the big picture (WordPress too)Webpage Caches - the big picture (WordPress too)
Webpage Caches - the big picture (WordPress too)Erich
 
Running PHP on Nginx / PHP wgtn
Running PHP on Nginx / PHP wgtnRunning PHP on Nginx / PHP wgtn
Running PHP on Nginx / PHP wgtnHarald Zeitlhofer
 
Accelerating Nginx Web Server Performance
Accelerating Nginx Web Server PerformanceAccelerating Nginx Web Server Performance
Accelerating Nginx Web Server PerformanceBruce Tolley
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
High Performance Php My Sql Scaling Techniques
High Performance Php My Sql Scaling TechniquesHigh Performance Php My Sql Scaling Techniques
High Performance Php My Sql Scaling TechniquesZendCon
 
Maximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXMaximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXNGINX, Inc.
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaTony Fabeen
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINXWallarm
 
How to be Successful with Responsive Sites (Koombea & NGINX) - English
How to be Successful with Responsive Sites (Koombea & NGINX) - EnglishHow to be Successful with Responsive Sites (Koombea & NGINX) - English
How to be Successful with Responsive Sites (Koombea & NGINX) - EnglishKoombea
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXNGINX, Inc.
 
Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Koombea
 
The 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference ArchitectureThe 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference ArchitectureNGINX, Inc.
 
NGINX High-performance Caching
NGINX High-performance CachingNGINX High-performance Caching
NGINX High-performance CachingNGINX, Inc.
 
Web page load speed optimization
Web page load speed optimizationWeb page load speed optimization
Web page load speed optimizationDmitry Dudin
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx InternalsJoshua Zhu
 

Destaque (18)

Webpage Caches - the big picture (WordPress too)
Webpage Caches - the big picture (WordPress too)Webpage Caches - the big picture (WordPress too)
Webpage Caches - the big picture (WordPress too)
 
Running PHP on Nginx / PHP wgtn
Running PHP on Nginx / PHP wgtnRunning PHP on Nginx / PHP wgtn
Running PHP on Nginx / PHP wgtn
 
5 critical-optimizations.v2
5 critical-optimizations.v25 critical-optimizations.v2
5 critical-optimizations.v2
 
Accelerating Nginx Web Server Performance
Accelerating Nginx Web Server PerformanceAccelerating Nginx Web Server Performance
Accelerating Nginx Web Server Performance
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
High Performance Php My Sql Scaling Techniques
High Performance Php My Sql Scaling TechniquesHigh Performance Php My Sql Scaling Techniques
High Performance Php My Sql Scaling Techniques
 
Maximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINXMaximizing PHP Performance with NGINX
Maximizing PHP Performance with NGINX
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINX
 
How to monitor NGINX
How to monitor NGINXHow to monitor NGINX
How to monitor NGINX
 
How to be Successful with Responsive Sites (Koombea & NGINX) - English
How to be Successful with Responsive Sites (Koombea & NGINX) - EnglishHow to be Successful with Responsive Sites (Koombea & NGINX) - English
How to be Successful with Responsive Sites (Koombea & NGINX) - English
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINX
 
Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?
 
The 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference ArchitectureThe 3 Models in the NGINX Microservices Reference Architecture
The 3 Models in the NGINX Microservices Reference Architecture
 
NGINX High-performance Caching
NGINX High-performance CachingNGINX High-performance Caching
NGINX High-performance Caching
 
Web page load speed optimization
Web page load speed optimizationWeb page load speed optimization
Web page load speed optimization
 
Nginx Internals
Nginx InternalsNginx Internals
Nginx Internals
 

Semelhante a Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup

Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbsvarien
 
Optimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x AppsOptimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x AppsJuan Basso
 
Tips for a Faster Website
Tips for a Faster WebsiteTips for a Faster Website
Tips for a Faster WebsiteRayed Alrashed
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuningJohn McCaffrey
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
A Holistic View of Website Performance
A Holistic View of Website PerformanceA Holistic View of Website Performance
A Holistic View of Website PerformanceRene Churchill
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimizationKaliop-slide
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website TuneupsJeff Wisniewski
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesStoyan Stefanov
 
SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!Brian Culver
 
Web performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.ukWeb performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.ukgareth53
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moondavejohnson
 
High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010Barry Abrahamson
 
Frontend performance
Frontend performanceFrontend performance
Frontend performancesacred 8
 
Shopzilla - Performance By Design
Shopzilla - Performance By DesignShopzilla - Performance By Design
Shopzilla - Performance By DesignTim Morrow
 
Accelerate SharePoint 2007 and 2010 websites and intranets mike iem - apti...
Accelerate SharePoint 2007 and 2010 websites and intranets    mike iem - apti...Accelerate SharePoint 2007 and 2010 websites and intranets    mike iem - apti...
Accelerate SharePoint 2007 and 2010 websites and intranets mike iem - apti...Aptimize
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 

Semelhante a Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup (20)

Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbs
 
Optimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x AppsOptimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x Apps
 
Tips for a Faster Website
Tips for a Faster WebsiteTips for a Faster Website
Tips for a Faster Website
 
Windy cityrails performance_tuning
Windy cityrails performance_tuningWindy cityrails performance_tuning
Windy cityrails performance_tuning
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Scaling 101 test
Scaling 101 testScaling 101 test
Scaling 101 test
 
Scaling 101
Scaling 101Scaling 101
Scaling 101
 
A Holistic View of Website Performance
A Holistic View of Website PerformanceA Holistic View of Website Performance
A Holistic View of Website Performance
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website Tuneups
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practices
 
SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!
 
Web performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.ukWeb performance - Analysing Heart.co.uk
Web performance - Analysing Heart.co.uk
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010
 
Frontend performance
Frontend performanceFrontend performance
Frontend performance
 
Shopzilla - Performance By Design
Shopzilla - Performance By DesignShopzilla - Performance By Design
Shopzilla - Performance By Design
 
Accelerate SharePoint 2007 and 2010 websites and intranets mike iem - apti...
Accelerate SharePoint 2007 and 2010 websites and intranets    mike iem - apti...Accelerate SharePoint 2007 and 2010 websites and intranets    mike iem - apti...
Accelerate SharePoint 2007 and 2010 websites and intranets mike iem - apti...
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 

Mais de Jonathan Klein

DIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest MagicDIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest MagicJonathan Klein
 
UXFest - RUM Distillation 101
UXFest - RUM Distillation 101UXFest - RUM Distillation 101
UXFest - RUM Distillation 101Jonathan Klein
 
Edge Conf Rendering Performance Panel
Edge Conf Rendering Performance PanelEdge Conf Rendering Performance Panel
Edge Conf Rendering Performance PanelJonathan Klein
 
Scaling PHP to 40 Million Uniques
Scaling PHP to 40 Million UniquesScaling PHP to 40 Million Uniques
Scaling PHP to 40 Million UniquesJonathan Klein
 
JSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web DesignJSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web DesignJonathan Klein
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesJonathan Klein
 
EscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend OptimizationEscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend OptimizationJonathan Klein
 
Design Camp Boston - Designing Faster Websites
Design Camp Boston - Designing Faster WebsitesDesign Camp Boston - Designing Faster Websites
Design Camp Boston - Designing Faster WebsitesJonathan Klein
 
Web performance introduction boston web performance meetup
Web performance introduction   boston web performance meetupWeb performance introduction   boston web performance meetup
Web performance introduction boston web performance meetupJonathan Klein
 

Mais de Jonathan Klein (9)

DIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest MagicDIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest Magic
 
UXFest - RUM Distillation 101
UXFest - RUM Distillation 101UXFest - RUM Distillation 101
UXFest - RUM Distillation 101
 
Edge Conf Rendering Performance Panel
Edge Conf Rendering Performance PanelEdge Conf Rendering Performance Panel
Edge Conf Rendering Performance Panel
 
Scaling PHP to 40 Million Uniques
Scaling PHP to 40 Million UniquesScaling PHP to 40 Million Uniques
Scaling PHP to 40 Million Uniques
 
JSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web DesignJSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web Design
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
 
EscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend OptimizationEscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend Optimization
 
Design Camp Boston - Designing Faster Websites
Design Camp Boston - Designing Faster WebsitesDesign Camp Boston - Designing Faster Websites
Design Camp Boston - Designing Faster Websites
 
Web performance introduction boston web performance meetup
Web performance introduction   boston web performance meetupWeb performance introduction   boston web performance meetup
Web performance introduction boston web performance meetup
 

Último

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup

  • 1. Web Performance, Scalability, and Testing Techniques Boston PHP Meetup Group – April 2011 Jonathan Klein jklein@csnstores.com @jonathanklein
  • 2. What We’ll Cover Why Listen to Me? Why Performance Matters Measuring Server Side Performance Speeding up the Server Frontend Optimization Measuring Full Page Load Time Homework
  • 3. What We’ll Cover Why Listen to Me? Why Performance Matters Measuring Server Side Performance Speeding up the Server Frontend Optimization Measuring Full Page Load Time Homework  Fun Performance Adventure!
  • 4. Introduction Senior Software Engineer/Performance Guy at CSN Stores Organizer of the Boston Web Performance Meetup Group CSN Stores Stats: ~1400 requests/sec for static content ~400 requests/sec for dynamic content ~10 million unique visitors per month On a typical Monday we serve 75,000,000 static files
  • 5. Currently converting all store code to PHP Windows Server  FreeBSD IIS  Lighttpd ~100,000 lines of ASP Classic  ~50,000 lines of PHP code ~5 weeks away from launch
  • 6. Why Do We Care about Performance? A Faster Website Will Make You More Money
  • 7.
  • 8. Firefox Firefox reduced the load time of their download page by 2.2 seconds Downloads went up 15.4% This could drive 60 MILLION yearly downloads
  • 9. Google Injected a 400ms delay into search 0.44% fewer searches/user 0.76% after 6 weeks After delay was removed, 0.21% fewer searches
  • 10. Yahoo! 400ms delay 5-9% drop in full-page traffic
  • 11. Direct Relationship Between Speed and Dollars http://www.phpied.com/the-performance-business-pitch/
  • 12.
  • 13. Server Side Monitoring Lots of Options: Paid: Coradiant dynaTrace Correlsense http://www.real-user-monitoring.com/ - Free Version Free: Access Logs Nagios Ganglia Hosted WebPagetest Selenium/dynaTrace Ajax Edition
  • 14. Server Side Monitoring <?php $start = microtime(true); …script content… $end = microtime(true); do_stuff(‘Description’, $end - $start); ?>
  • 15. WTH is do_stuff()? do_stuff() can do one of: Log to a database (not ideal) Write to a text file (eww) Make a StatsD call over UDP (good) -http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/
  • 17. Be Careful What You Watch Averages can be misleading Better to look at percentiles
  • 18.
  • 19.
  • 20. What Does a Scalability Problem Look Like?
  • 21. What Does a Scalability Problem Look Like?
  • 22. What Does a Scalability Problem Look Like?
  • 24. What can you do? Start with the Database Run a database trace Filter: Queries > 50ms Filter: Reads > 1000 Start with the worst ones and optimize
  • 25. Okay, I’ll “Optimize” Look at execution plan Remove calls to remote servers
  • 26. Database Optimizations Reduce Joins Select * from  Select Foo, Bar, Baz from… Minimize/consolidate subqueries Add indexes where needed We added one index: Procedure dropped from 3.5 sec & 4500 reads to .06 sec and 130 reads! Be careful with where clauses (don’t calculate stuff in them)
  • 27. Example SELECT id, name, salary FROM employee WHERE salary < 25000; NOT SELECT id, name, salary FROM employee WHERE salary + 10000 < 35000;
  • 28. Example SELECT id, name, salary FROM employee WHERE salary < 25000; NOT SELECT id, name, salary FROM employee WHERE salary + 10000 < 35000;
  • 29. Caching The Fastest DB Query is the One That’s Never Made
  • 30. Memcached Caching layer between database and webserver Can hold PHP objects and arrays
  • 31. Memcached $m = new Memcached(); $m->pconnect(‘1.2.3.4', 11211); $m->set(‘foo’, $bar, 600); $baz = $m->get(‘foo’);
  • 33. Install APC APC – Alternative PHP Cache Opcode Cache User Cache Awesome!
  • 36. PHP Code Optimizations Set the max loop value before the loop: $max = count($rows); for ($i = 0; $i < $max; $i++) { echo $i; } require_once() is slow Minimize use of define() Yes, single quotes are slightly faster than double quotes
  • 37. PHP Code Optimizations Could go on and on… http://www.wmtips.com/php/tips-optimizing-php-code.htm Minimal returns Find the hotspots in your application and fix them
  • 38. Example… Homepage takes 5 seconds to load Optimize PHP… Reduce PHP execution time by 50%! But wait! PHP execution was only taking 100ms Saves you 50ms in load time 1% of total page load
  • 39. HipHop for PHP Built by Facebook and Open Sourced Compiles PHP into C++ Currently supports PHP 5.2 http://developers.facebook.com/blog/post/358/ https://github.com/facebook/hiphop-php
  • 41. Webserver Optimizations Pick the right one Lighttpd/Nginx instead of Apache Designed to solve the C10K problem Lighttpd Used By: Youtube Wikipedia Meebo
  • 42.
  • 43. If you are stuck on Apache… mod_deflate Gzips content for faster transfer times mod_pagespeed Automatic performance improvements KeepAlives on Server won’t create a new connection for every resource
  • 48.
  • 50. Client side Optimization is Critical 80-90% of load time takes place on the client For mobile  97%
  • 51. Best Practices Reduce HTTP Requests Combine CSS, JS Use image sprites .classname{ background: url(sprite.png) no-repeat 0 -432px; }
  • 52. Best Practices Minify CSS/JS Strip comments and whitespace Automate this – YUI Compressor http://developer.yahoo.com/yui/compressor/ Gzip all text HTML CSS JS Optimize Images…
  • 53. Image Optimization For graphics use PNG8 (256 color limitation) No more .gif (unless animated) JPEGs can be saved at lower quality (75%-80%) Smush all images
  • 54. Smush Your Images! - smushit.com
  • 55. JPEG Quality 100% 80% 182 KB 48 KB
  • 57. How Do You Measure Load Time? Google Webmaster Tools WebPagetest (www.webpagetest.org) Yottaa.com Firebug YSlow PageSpeed Dynatrace Ajax Edition
  • 58.
  • 59.
  • 60.
  • 61. CDN – Content Delivery Network
  • 62. Lots of Options Amazon CloudFront MaxCDN Limelight Level3 Akamai Cotendo
  • 63.
  • 64. Expires Headers Set a far future date on static resources CSS/JS/Images Release new version by changing the filename Benefits repeat visitors and repeat page views
  • 66.
  • 68.
  • 69.
  • 70.
  • 71.
  • 74.
  • 75.
  • 76.
  • 77. Resources http://www.webperformancecentral.com/wiki/WebPagetest/Optimization_Help http://developer.yahoo.com/performance/ http://code.google.com/speed/ High Performance Websites (Book) Even Faster Websites (Book)
  • 78.
  • 79. Conclusion “Speed is the most important feature. If your application is slow, people won’t use it. I see this more with mainstream users than I do with power users...If something is slow, they’re just gone.” - Fred Wilson (10 Golden Principles of Web Apps)
  • 80. Conclusion “Speed is the most important feature. If your application is slow, people won’t use it. I see this more with mainstream users than I do with power users...If something is slow, they’re just gone.” - Fred Wilson (10 Golden Principles of Web Apps)
  • 81. ?> We’re Hiring! www.csnstores.com/careers Get In Touch: www.meetup.com/Web-Performance-Boston/ jklein@csnstores.com @jonathanklein