SlideShare una empresa de Scribd logo
1 de 50
Descargar para leer sin conexión
Jason Ragsdale
Sr.TechnicalYahoo
Yahoo!
Web Speed & Scalability
Friday, November 12, 2010
• How to build a bigger, faster, and more
reliable website
• You will learn the concepts of Speed and
Scalability
• Specific Examples of Caching, Load
Balancing and testing tools.
Introduction
Friday, November 12, 2010
• What is Scalability?
• Avoiding Failure
• High Availability?!?!?
• Monitoring
• Release Cycles
• Fault Tolerance
• Load Balancing
• Static Content
• Caching
• Yslow & PageSpeed
Agenda
Friday, November 12, 2010
• Horizontal Scalability
• Capacity can be
increased just by
adding more
hardware/software
• Best solution
• Does not
guarantee that you
are safe
• Up (Vertical) Scalability
• Capacity can be
increased by adding
more Disk Storage,
RAM , Processors
• Expensive
• Should only be
used if Horizontal
will not work for
you
What is Scalability?
Friday, November 12, 2010
• Capital investment will be made
• The system will be more complex
• Maintenance costs will increase
• Time will be required to act
Scalability
Considerations
Friday, November 12, 2010
• Good Planning
• Have a plan for whatever you are about to do to
your system, and most importantly, have a roll-
back plan if and when things do not work the
way you expected.
Avoiding Failure
Friday, November 12, 2010
• Functional and Unit Testing
• Automated test do not catch everything that
can go wrong, but they are very good at catching
bugs introduced by changes elsewhere in your
code base
• Unit Testing (PHPUnit, Simpletest)
• Function Testing (selenium)
Avoiding Failure
Friday, November 12, 2010
• Control Change (Version Control)
• USE IT!!!! There is no better way even as a single
developer to keep your codebase safe from bad
changes
Avoiding Failure
Friday, November 12, 2010
• /trunk/
• Used for all mainline development
• /branches
• Used to do development that needs to be
separate from the trunk code
• /tags/
• Holds copies of production ready code
• Do not useVersion Control as a backup solution,
backup yourVCS separately
Version Control in Action
Friday, November 12, 2010
• What is “five nines” 99.999%?
• Do the math, 60 seconds * 60 minutes *
24 hours * 365 days
• 31,536,000 seconds of uptime a year
• 99.999 * 31536000 = 315.36 seconds
of downtime a year
High Availability?!?!?!
Friday, November 12, 2010
• Understand the goodness of “Planned
maintenance periods”
• There are things you will need to do to
your systems on a periodic basis I.E.
Database Cleanup, Disk Defrag, Software/
Hardware Upgrades
High Availability?!?!?!
Friday, November 12, 2010
• You can stagger your maintenance periods
if you have enough servers so you have no
customer downtime, just a reduction in
capacity
High Availability?!?!?!
Friday, November 12, 2010
• No matter how stable your code is or how
reliable your hardware, you will have failure
Monitoring
Friday, November 12, 2010
• Top Down (Business Monitors)
• Monitor the application as the customer
interacts with it
Monitoring Methods
Friday, November 12, 2010
Monitoring Methods
• Bottom Up (System Monitors)
• Most commonly used
• Monitors the base components of your application like
• Disk Space
• Network speed
• Database Statistics
• By no means bad, but without Business Monitoring you will not be able
to catch all failures
Friday, November 12, 2010
• SNMP Support
• Can support most systems out there
• Extensibility
• Ability to plugin custom monitoring packages
• Flexible notifications
• Handle notifying operators and escalating issues if they are not looked
into
• Custom reaction
• In the event of errors that can not be diagnosed by computers, need to
be able to notify a human to do further investigation
Criteria For A Monitoring System
Friday, November 12, 2010
• Complex scheduling
• Ability to set the monitoring frequency and timing per monitoring item
• Maintenance scheduling
• Monitors should never be taken offline, they need to be smart enough to
know when a maintenance period is in effect
• Event acknowledgment
• Ability to understand when a event needs to be paged to a human at
2am, and when it shouldn't
• Service dependencies
• You need to monitor all points between your monitoring system and the
client.This includes Firewalls, Routers, Switches
Criteria For A Monitoring System
Friday, November 12, 2010
• Basic Release Cycle
• Development
• Things are expected to break
• Staging
• QA and bug fixing a build before release
• Production
• Only serious bug fixes are pushed
Release Cycles
Friday, November 12, 2010
• Keep in mind that reality has priority over “Best
Practice”
• You can and will have to release from
development… it happens
Release Cycles
Friday, November 12, 2010
router
switch
www-1-1 www-1-2
Intertubes
router
switch
www-1-1 www-1-2
Intertubes
router
switch
Fault Tolerance
Friday, November 12, 2010
• Load Balancing is NOT HA
• Balancing is meant to spread the workload
of requests across the cluster
Load Balancing
Friday, November 12, 2010
• Round robin
• One request per server in a uniform
rotation
Balancing Approaches
Friday, November 12, 2010
• Least connections
• The faster the machine processes
requests the more it will receive
Balancing Approaches
Friday, November 12, 2010
• Predictive
• Usually based on Round robin or Least
connections with some custom code
Balancing Approaches
Friday, November 12, 2010
• Available resources
• Not a good choice, bad performance
Balancing Approaches
Friday, November 12, 2010
• Random
• Pure random distribution of requests
• Weighted random
• Random with a preference to specific
machines
Balancing Approaches
Friday, November 12, 2010
• Static content examples
• Images
• CSS
• JS
• Any non dynamic element
Static Content
Friday, November 12, 2010
• Serving these items from a dedicated
server fees up your web process for actual
dynamic code, intern increasing your
capacity and response speed
• On you static server you can use
lightHTTP, which is very quick at serving
static content compared to apache
(Although apache 2.2.x is much better than
1.3.x)
Static Content
Friday, November 12, 2010
• Layered / Transport Cache
• “Transparent”
• Placed in-front of your hardware and
caches requests before they hit your
webserver
Types of Caching
Friday, November 12, 2010
• Integrated (Look-Aside) Cache
• Computational Reuse technique
• Used where the cost of storing the
results of a computation and later
finding them again is less expensive
than performing the computation again
Types of Caching
Friday, November 12, 2010
• Write-Thru Caches
• Application is responsible for updating
the Cache and Datastore when changes
are made
• Write-Back Caches
• All data changes are made to the cache
• Cache layer is responsible for modifying
the backend datastore
Types of Caching
Friday, November 12, 2010
• Distributed Cache
• Using several machines to cache data,
distributing the data and load
• Memcached can do this very simply
Types of Caching
Friday, November 12, 2010
• It is a high-performance, distributed object
caching system
Memcahed
Friday, November 12, 2010
• It is simple to setup and use
• # ./memcached -d -m 2048 -l 10.0.0.40 -p 11211
Memcahed
Friday, November 12, 2010
• It is not designed to be redundant
• If you loose data you memcache will
repopulate the data as it is accessed
Memcahed
Friday, November 12, 2010
• It provides no security to your cache
• “Memcached is the soft, doughy underbelly of
your application. Part of what makes the clients
and server lightweight is the complete lack of
authentication. New connections are fast, and
server configuration is nonexistent. If you wish
to restrict access, you may use a firewall, or have
memcached listen via unix domain sockets.”
Memcahed
Friday, November 12, 2010
• Alternative PHP Cache
• The Alternative PHP Cache (APC) is a free and open
opcode cache for PHP. It was conceived of to provide a
free, open, and robust framework for caching and
optimizing PHP intermediate code.
• Just enabling APC will transparently cache your code as
you use it, no code changes required on your side
• Provides a cheap caching layer that can be shared on a
between all apache processes on one machine
APC and why it’s your friend
Friday, November 12, 2010
• Based on 13 principles from http://
developer.yahoo.com/performance/
rules.html
• 1.) Make fewer HTTP requests
• 80% of the end-user response time is
spent on the front-end. Most of this
YSlow
Friday, November 12, 2010
• Based on 13 principles from
• http://developer.yahoo.com/performance/rules.html
YSlow
Friday, November 12, 2010
• Make fewer HTTP requests
• Use a CDN
• Add an Expires header
• Gzip components
YSlow
Friday, November 12, 2010
• Put CSS at the top
• Put JS at the bottom
• Avoid CSS expressions
• Make JS and CSS External
YSlow
Friday, November 12, 2010
• Reduce DNS lookups
• Minify JS
• Avoid redirects
• Remove duplicate scripts
• Configure Etags
• Make AJAX cachable
YSlow
Friday, November 12, 2010
• http://code.google.com/speed/page-speed
• The Page Speed family consists of several
products.Web developers can use the Page Speed
extension for Firefox/Firebug to analyze
performance issues while developing web pages.
Apache web hosters can use mod_pagespeed, a
module for the Apache™ HTTP Server that
automatically optimizes web pages and their
resources at serving time.
PageSpeed
Friday, November 12, 2010
• Adds client-side latency instrumentation.
• Improves cacheability.
• Removes unnecessary whitespace in HTML.
• Combines multiple <head> elements & CSS files into one.
• Moves CSS into the <head> element.
• Removes unnecessary attributes in HTML tags.
• Inlines small external CSS & Javascript files.
mod_page_speed
Friday, November 12, 2010
• Moves large inline <style> & <script> tags into external files for cacheability.
• Removes unnecessary quotes in HTML tags.
• Removes HTML comments.
• Minifies CSS.
• Rescales, and compresses images; inlines small ones.
• Minifies Javascript.
mod_page_speed
Friday, November 12, 2010
# enable expirations
ExpiresActive On
# expire GIF images after a month in the client's cache
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css A2592000
ExpiresByType application/x-javascript A2592000
# disable ETags
FileETag None
Example apache 2.x performance config
Friday, November 12, 2010
# Gzip Compression
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work.You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI 
.(?:gif|jpe?g|png|mp3)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header appendVary User-Agent env=!dont-vary
Example apache 2.x
performance config
Friday, November 12, 2010
Questions?
Friday, November 12, 2010
• YSlow: http://developer.yahoo.com/yslow/
• Rules: http://developer.yahoo.com/performance/rules.html
• Scalable Internet Architectures
• By Theo Schlossnagle
• APC: http://us3.php.net/apc
• Memcahed: http://www.danga.com/memcached/
• Selenium: http://www.openqa.org/selenium/
• Simpletest: http://simpletest.org/
• PHPUnit: http://www.phpunit.de/
Links & Information
Friday, November 12, 2010
• http://joind.in/talk/view/2355
Please Complete An
Evaluation Form
Friday, November 12, 2010

Más contenido relacionado

La actualidad más candente

Why new hardware may not make SQL Server faster
Why new hardware may not make SQL Server fasterWhy new hardware may not make SQL Server faster
Why new hardware may not make SQL Server fasterSolarWinds
 
Distributed caching with java JCache
Distributed caching with java JCacheDistributed caching with java JCache
Distributed caching with java JCacheKasun Gajasinghe
 
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik Brandsberg
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik BrandsbergScaling SQL Write-Master Database Clusters With Redis Labs: Erik Brandsberg
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik BrandsbergRedis Labs
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterMongoDB
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best PracticesRatnesh kumar, CSM
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...elliando dias
 
VMworld 2014: Virtualizing Databases
VMworld 2014: Virtualizing DatabasesVMworld 2014: Virtualizing Databases
VMworld 2014: Virtualizing DatabasesVMworld
 
Scaling Up and Out your Virtualized SQL Servers
Scaling Up and Out your Virtualized SQL ServersScaling Up and Out your Virtualized SQL Servers
Scaling Up and Out your Virtualized SQL Serversheraflux
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcacheChris Westin
 
Top 10 Application Problems
Top 10 Application ProblemsTop 10 Application Problems
Top 10 Application ProblemsAppDynamics
 
Mobile & Desktop Cache 2.0: How To Create A Scriptable Cache
Mobile & Desktop Cache 2.0: How To Create A Scriptable CacheMobile & Desktop Cache 2.0: How To Create A Scriptable Cache
Mobile & Desktop Cache 2.0: How To Create A Scriptable CacheBlaze Software Inc.
 
Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Comsysto Reply GmbH
 
Cassandra TK 2014 - Large Nodes
Cassandra TK 2014 - Large NodesCassandra TK 2014 - Large Nodes
Cassandra TK 2014 - Large Nodesaaronmorton
 
Proxysql use case scenarios fosdem17
Proxysql use case scenarios    fosdem17Proxysql use case scenarios    fosdem17
Proxysql use case scenarios fosdem17Alkin Tezuysal
 

La actualidad más candente (20)

Why new hardware may not make SQL Server faster
Why new hardware may not make SQL Server fasterWhy new hardware may not make SQL Server faster
Why new hardware may not make SQL Server faster
 
Distributed caching with java JCache
Distributed caching with java JCacheDistributed caching with java JCache
Distributed caching with java JCache
 
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik Brandsberg
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik BrandsbergScaling SQL Write-Master Database Clusters With Redis Labs: Erik Brandsberg
Scaling SQL Write-Master Database Clusters With Redis Labs: Erik Brandsberg
 
Caching
CachingCaching
Caching
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your Cluster
 
AppFabric Velocity
AppFabric VelocityAppFabric Velocity
AppFabric Velocity
 
Drupal performance optimization Best Practices
Drupal performance optimization Best PracticesDrupal performance optimization Best Practices
Drupal performance optimization Best Practices
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
Distributed Caching Using the JCACHE API and ehcache, Including a Case Study ...
 
JCache Using JCache
JCache Using JCacheJCache Using JCache
JCache Using JCache
 
VMworld 2014: Virtualizing Databases
VMworld 2014: Virtualizing DatabasesVMworld 2014: Virtualizing Databases
VMworld 2014: Virtualizing Databases
 
Scaling Up and Out your Virtualized SQL Servers
Scaling Up and Out your Virtualized SQL ServersScaling Up and Out your Virtualized SQL Servers
Scaling Up and Out your Virtualized SQL Servers
 
Building low latency java applications with ehcache
Building low latency java applications with ehcacheBuilding low latency java applications with ehcache
Building low latency java applications with ehcache
 
Five steps perform_2013
Five steps perform_2013Five steps perform_2013
Five steps perform_2013
 
Top 10 Application Problems
Top 10 Application ProblemsTop 10 Application Problems
Top 10 Application Problems
 
Mobile & Desktop Cache 2.0: How To Create A Scriptable Cache
Mobile & Desktop Cache 2.0: How To Create A Scriptable CacheMobile & Desktop Cache 2.0: How To Create A Scriptable Cache
Mobile & Desktop Cache 2.0: How To Create A Scriptable Cache
 
Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16Caching and JCache with Greg Luck 18.02.16
Caching and JCache with Greg Luck 18.02.16
 
Cassandra TK 2014 - Large Nodes
Cassandra TK 2014 - Large NodesCassandra TK 2014 - Large Nodes
Cassandra TK 2014 - Large Nodes
 
Proxysql use case scenarios fosdem17
Proxysql use case scenarios    fosdem17Proxysql use case scenarios    fosdem17
Proxysql use case scenarios fosdem17
 
5 critical-optimizations.v2
5 critical-optimizations.v25 critical-optimizations.v2
5 critical-optimizations.v2
 

Destacado

Tulsa techfest2010 security
Tulsa techfest2010   securityTulsa techfest2010   security
Tulsa techfest2010 securityJason Ragsdale
 
Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Jason Ragsdale
 
Test Driven Development - 09/2009
Test Driven Development - 09/2009Test Driven Development - 09/2009
Test Driven Development - 09/2009Jason Ragsdale
 
RIA with Flex & PHP - Tulsa TechFest 2009
RIA with Flex & PHP  - Tulsa TechFest 2009RIA with Flex & PHP  - Tulsa TechFest 2009
RIA with Flex & PHP - Tulsa TechFest 2009Jason Ragsdale
 

Destacado (7)

Tulsa techfest2010 security
Tulsa techfest2010   securityTulsa techfest2010   security
Tulsa techfest2010 security
 
Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009Test Driven Development - Tulsa TechFest 2009
Test Driven Development - Tulsa TechFest 2009
 
What Is Security
What Is SecurityWhat Is Security
What Is Security
 
Test Driven Development - 09/2009
Test Driven Development - 09/2009Test Driven Development - 09/2009
Test Driven Development - 09/2009
 
Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
 
RIA with Flex & PHP - Tulsa TechFest 2009
RIA with Flex & PHP  - Tulsa TechFest 2009RIA with Flex & PHP  - Tulsa TechFest 2009
RIA with Flex & PHP - Tulsa TechFest 2009
 
Yii Framework
Yii FrameworkYii Framework
Yii Framework
 

Similar a Tulsa tech fest 2010 - web speed and scalability

WebsitePerformance
WebsitePerformanceWebsitePerformance
WebsitePerformanceVivek Jain
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Jess Coburn
 
The 5 Minute DBA-DBA Skills for Non-DBA
The 5 Minute DBA-DBA Skills for Non-DBAThe 5 Minute DBA-DBA Skills for Non-DBA
The 5 Minute DBA-DBA Skills for Non-DBApercona2013
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckLuis Guirigay
 
Scaling apps for the big time
Scaling apps for the big timeScaling apps for the big time
Scaling apps for the big timeproitconsult
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalChapter Three
 
Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18BIWUG
 
Technical track-afterimaging Progress Database
Technical track-afterimaging Progress DatabaseTechnical track-afterimaging Progress Database
Technical track-afterimaging Progress DatabaseVinh Nguyen
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best PracticesNagios
 
E2 evc 3-2-1-rule - mikeresseler
E2 evc   3-2-1-rule - mikeresselerE2 evc   3-2-1-rule - mikeresseler
E2 evc 3-2-1-rule - mikeresselerMike Resseler
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Hadoop operations-2015-hadoop-summit-san-jose-v5
Hadoop operations-2015-hadoop-summit-san-jose-v5Hadoop operations-2015-hadoop-summit-san-jose-v5
Hadoop operations-2015-hadoop-summit-san-jose-v5Chris Nauroth
 
Hadoop Operations - Best Practices from the Field
Hadoop Operations - Best Practices from the FieldHadoop Operations - Best Practices from the Field
Hadoop Operations - Best Practices from the FieldDataWorks Summit
 
Website Performance
Website PerformanceWebsite Performance
Website PerformanceHugo Fonseca
 
System hardening - OS and Application
System hardening - OS and ApplicationSystem hardening - OS and Application
System hardening - OS and Applicationedavid2685
 
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLPerformance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLTriNimbus
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMathew Beane
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilitycherryhillco
 

Similar a Tulsa tech fest 2010 - web speed and scalability (20)

WebsitePerformance
WebsitePerformanceWebsitePerformance
WebsitePerformance
 
Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11Orlando DNN Usergroup Pres 12/06/11
Orlando DNN Usergroup Pres 12/06/11
 
The 5 Minute DBA-DBA Skills for Non-DBA
The 5 Minute DBA-DBA Skills for Non-DBAThe 5 Minute DBA-DBA Skills for Non-DBA
The 5 Minute DBA-DBA Skills for Non-DBA
 
Performance stack
Performance stackPerformance stack
Performance stack
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health Check
 
Scaling apps for the big time
Scaling apps for the big timeScaling apps for the big time
Scaling apps for the big time
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18
 
Technical track-afterimaging Progress Database
Technical track-afterimaging Progress DatabaseTechnical track-afterimaging Progress Database
Technical track-afterimaging Progress Database
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best Practices
 
E2 evc 3-2-1-rule - mikeresseler
E2 evc   3-2-1-rule - mikeresselerE2 evc   3-2-1-rule - mikeresseler
E2 evc 3-2-1-rule - mikeresseler
 
My site is slow
My site is slowMy site is slow
My site is slow
 
Hadoop operations-2015-hadoop-summit-san-jose-v5
Hadoop operations-2015-hadoop-summit-san-jose-v5Hadoop operations-2015-hadoop-summit-san-jose-v5
Hadoop operations-2015-hadoop-summit-san-jose-v5
 
Hadoop Operations - Best Practices from the Field
Hadoop Operations - Best Practices from the FieldHadoop Operations - Best Practices from the Field
Hadoop Operations - Best Practices from the Field
 
Website Performance
Website PerformanceWebsite Performance
Website Performance
 
System hardening - OS and Application
System hardening - OS and ApplicationSystem hardening - OS and Application
System hardening - OS and Application
 
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLPerformance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling Magento
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 

Tulsa tech fest 2010 - web speed and scalability

  • 1. Jason Ragsdale Sr.TechnicalYahoo Yahoo! Web Speed & Scalability Friday, November 12, 2010
  • 2. • How to build a bigger, faster, and more reliable website • You will learn the concepts of Speed and Scalability • Specific Examples of Caching, Load Balancing and testing tools. Introduction Friday, November 12, 2010
  • 3. • What is Scalability? • Avoiding Failure • High Availability?!?!? • Monitoring • Release Cycles • Fault Tolerance • Load Balancing • Static Content • Caching • Yslow & PageSpeed Agenda Friday, November 12, 2010
  • 4. • Horizontal Scalability • Capacity can be increased just by adding more hardware/software • Best solution • Does not guarantee that you are safe • Up (Vertical) Scalability • Capacity can be increased by adding more Disk Storage, RAM , Processors • Expensive • Should only be used if Horizontal will not work for you What is Scalability? Friday, November 12, 2010
  • 5. • Capital investment will be made • The system will be more complex • Maintenance costs will increase • Time will be required to act Scalability Considerations Friday, November 12, 2010
  • 6. • Good Planning • Have a plan for whatever you are about to do to your system, and most importantly, have a roll- back plan if and when things do not work the way you expected. Avoiding Failure Friday, November 12, 2010
  • 7. • Functional and Unit Testing • Automated test do not catch everything that can go wrong, but they are very good at catching bugs introduced by changes elsewhere in your code base • Unit Testing (PHPUnit, Simpletest) • Function Testing (selenium) Avoiding Failure Friday, November 12, 2010
  • 8. • Control Change (Version Control) • USE IT!!!! There is no better way even as a single developer to keep your codebase safe from bad changes Avoiding Failure Friday, November 12, 2010
  • 9. • /trunk/ • Used for all mainline development • /branches • Used to do development that needs to be separate from the trunk code • /tags/ • Holds copies of production ready code • Do not useVersion Control as a backup solution, backup yourVCS separately Version Control in Action Friday, November 12, 2010
  • 10. • What is “five nines” 99.999%? • Do the math, 60 seconds * 60 minutes * 24 hours * 365 days • 31,536,000 seconds of uptime a year • 99.999 * 31536000 = 315.36 seconds of downtime a year High Availability?!?!?! Friday, November 12, 2010
  • 11. • Understand the goodness of “Planned maintenance periods” • There are things you will need to do to your systems on a periodic basis I.E. Database Cleanup, Disk Defrag, Software/ Hardware Upgrades High Availability?!?!?! Friday, November 12, 2010
  • 12. • You can stagger your maintenance periods if you have enough servers so you have no customer downtime, just a reduction in capacity High Availability?!?!?! Friday, November 12, 2010
  • 13. • No matter how stable your code is or how reliable your hardware, you will have failure Monitoring Friday, November 12, 2010
  • 14. • Top Down (Business Monitors) • Monitor the application as the customer interacts with it Monitoring Methods Friday, November 12, 2010
  • 15. Monitoring Methods • Bottom Up (System Monitors) • Most commonly used • Monitors the base components of your application like • Disk Space • Network speed • Database Statistics • By no means bad, but without Business Monitoring you will not be able to catch all failures Friday, November 12, 2010
  • 16. • SNMP Support • Can support most systems out there • Extensibility • Ability to plugin custom monitoring packages • Flexible notifications • Handle notifying operators and escalating issues if they are not looked into • Custom reaction • In the event of errors that can not be diagnosed by computers, need to be able to notify a human to do further investigation Criteria For A Monitoring System Friday, November 12, 2010
  • 17. • Complex scheduling • Ability to set the monitoring frequency and timing per monitoring item • Maintenance scheduling • Monitors should never be taken offline, they need to be smart enough to know when a maintenance period is in effect • Event acknowledgment • Ability to understand when a event needs to be paged to a human at 2am, and when it shouldn't • Service dependencies • You need to monitor all points between your monitoring system and the client.This includes Firewalls, Routers, Switches Criteria For A Monitoring System Friday, November 12, 2010
  • 18. • Basic Release Cycle • Development • Things are expected to break • Staging • QA and bug fixing a build before release • Production • Only serious bug fixes are pushed Release Cycles Friday, November 12, 2010
  • 19. • Keep in mind that reality has priority over “Best Practice” • You can and will have to release from development… it happens Release Cycles Friday, November 12, 2010
  • 21. • Load Balancing is NOT HA • Balancing is meant to spread the workload of requests across the cluster Load Balancing Friday, November 12, 2010
  • 22. • Round robin • One request per server in a uniform rotation Balancing Approaches Friday, November 12, 2010
  • 23. • Least connections • The faster the machine processes requests the more it will receive Balancing Approaches Friday, November 12, 2010
  • 24. • Predictive • Usually based on Round robin or Least connections with some custom code Balancing Approaches Friday, November 12, 2010
  • 25. • Available resources • Not a good choice, bad performance Balancing Approaches Friday, November 12, 2010
  • 26. • Random • Pure random distribution of requests • Weighted random • Random with a preference to specific machines Balancing Approaches Friday, November 12, 2010
  • 27. • Static content examples • Images • CSS • JS • Any non dynamic element Static Content Friday, November 12, 2010
  • 28. • Serving these items from a dedicated server fees up your web process for actual dynamic code, intern increasing your capacity and response speed • On you static server you can use lightHTTP, which is very quick at serving static content compared to apache (Although apache 2.2.x is much better than 1.3.x) Static Content Friday, November 12, 2010
  • 29. • Layered / Transport Cache • “Transparent” • Placed in-front of your hardware and caches requests before they hit your webserver Types of Caching Friday, November 12, 2010
  • 30. • Integrated (Look-Aside) Cache • Computational Reuse technique • Used where the cost of storing the results of a computation and later finding them again is less expensive than performing the computation again Types of Caching Friday, November 12, 2010
  • 31. • Write-Thru Caches • Application is responsible for updating the Cache and Datastore when changes are made • Write-Back Caches • All data changes are made to the cache • Cache layer is responsible for modifying the backend datastore Types of Caching Friday, November 12, 2010
  • 32. • Distributed Cache • Using several machines to cache data, distributing the data and load • Memcached can do this very simply Types of Caching Friday, November 12, 2010
  • 33. • It is a high-performance, distributed object caching system Memcahed Friday, November 12, 2010
  • 34. • It is simple to setup and use • # ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 Memcahed Friday, November 12, 2010
  • 35. • It is not designed to be redundant • If you loose data you memcache will repopulate the data as it is accessed Memcahed Friday, November 12, 2010
  • 36. • It provides no security to your cache • “Memcached is the soft, doughy underbelly of your application. Part of what makes the clients and server lightweight is the complete lack of authentication. New connections are fast, and server configuration is nonexistent. If you wish to restrict access, you may use a firewall, or have memcached listen via unix domain sockets.” Memcahed Friday, November 12, 2010
  • 37. • Alternative PHP Cache • The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. It was conceived of to provide a free, open, and robust framework for caching and optimizing PHP intermediate code. • Just enabling APC will transparently cache your code as you use it, no code changes required on your side • Provides a cheap caching layer that can be shared on a between all apache processes on one machine APC and why it’s your friend Friday, November 12, 2010
  • 38. • Based on 13 principles from http:// developer.yahoo.com/performance/ rules.html • 1.) Make fewer HTTP requests • 80% of the end-user response time is spent on the front-end. Most of this YSlow Friday, November 12, 2010
  • 39. • Based on 13 principles from • http://developer.yahoo.com/performance/rules.html YSlow Friday, November 12, 2010
  • 40. • Make fewer HTTP requests • Use a CDN • Add an Expires header • Gzip components YSlow Friday, November 12, 2010
  • 41. • Put CSS at the top • Put JS at the bottom • Avoid CSS expressions • Make JS and CSS External YSlow Friday, November 12, 2010
  • 42. • Reduce DNS lookups • Minify JS • Avoid redirects • Remove duplicate scripts • Configure Etags • Make AJAX cachable YSlow Friday, November 12, 2010
  • 43. • http://code.google.com/speed/page-speed • The Page Speed family consists of several products.Web developers can use the Page Speed extension for Firefox/Firebug to analyze performance issues while developing web pages. Apache web hosters can use mod_pagespeed, a module for the Apache™ HTTP Server that automatically optimizes web pages and their resources at serving time. PageSpeed Friday, November 12, 2010
  • 44. • Adds client-side latency instrumentation. • Improves cacheability. • Removes unnecessary whitespace in HTML. • Combines multiple <head> elements & CSS files into one. • Moves CSS into the <head> element. • Removes unnecessary attributes in HTML tags. • Inlines small external CSS & Javascript files. mod_page_speed Friday, November 12, 2010
  • 45. • Moves large inline <style> & <script> tags into external files for cacheability. • Removes unnecessary quotes in HTML tags. • Removes HTML comments. • Minifies CSS. • Rescales, and compresses images; inlines small ones. • Minifies Javascript. mod_page_speed Friday, November 12, 2010
  • 46. # enable expirations ExpiresActive On # expire GIF images after a month in the client's cache ExpiresByType image/gif A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType text/css A2592000 ExpiresByType application/x-javascript A2592000 # disable ETags FileETag None Example apache 2.x performance config Friday, November 12, 2010
  • 47. # Gzip Compression # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine BrowserMatch bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 # the above regex won't work.You can use the following # workaround to get the desired effect: BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|mp3)$ no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header appendVary User-Agent env=!dont-vary Example apache 2.x performance config Friday, November 12, 2010
  • 49. • YSlow: http://developer.yahoo.com/yslow/ • Rules: http://developer.yahoo.com/performance/rules.html • Scalable Internet Architectures • By Theo Schlossnagle • APC: http://us3.php.net/apc • Memcahed: http://www.danga.com/memcached/ • Selenium: http://www.openqa.org/selenium/ • Simpletest: http://simpletest.org/ • PHPUnit: http://www.phpunit.de/ Links & Information Friday, November 12, 2010
  • 50. • http://joind.in/talk/view/2355 Please Complete An Evaluation Form Friday, November 12, 2010