SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
Odoo
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
tkramar
 
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
Fotis Alexandrou
 
Web Application Optimization Techniques
Web Application Optimization TechniquesWeb Application Optimization Techniques
Web Application Optimization Techniques
takinbo
 

Was ist angesagt? (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)
 

Andere mochten auch

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
Tony Fabeen
 
Web page load speed optimization
Web page load speed optimizationWeb page load speed optimization
Web page load speed optimization
Dmitry Dudin
 

Andere mochten auch (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
 

Ähnlich wie Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup

Magento performancenbs
Magento performancenbsMagento performancenbs
Magento performancenbs
varien
 
Optimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x AppsOptimizing CakePHP 2.x Apps
Optimizing CakePHP 2.x Apps
Juan Basso
 
Tips for a Faster Website
Tips for a Faster WebsiteTips for a Faster Website
Tips for a Faster Website
Rayed Alrashed
 
Fast and Easy Website Tuneups
Fast and Easy Website TuneupsFast and Easy Website Tuneups
Fast and Easy Website Tuneups
Jeff 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 practices
Stoyan Stefanov
 
High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010High Performance WordPress - WordCamp Jerusalem 2010
High Performance WordPress - WordCamp Jerusalem 2010
Barry Abrahamson
 
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 Ferrari
Joseph Scott
 

Ähnlich wie 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
 

Mehr von Jonathan 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 meetup
Jonathan Klein
 

Mehr von 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
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

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