SlideShare a Scribd company logo
1 of 32
Download to read offline
Apache Web
                       Performance
                       Leveraging Apache to make your
                       site fly




Friday, March 16, 12                                    1
Who am I?
                                &
                   Why would you listen to me?




Friday, March 16, 12                             2
Devon Hillard
                       Web Application Architect

                       Built 10MinuteMail

                       Run Spark::red, an enterprise
                       eCommerce Hosting company

                       Complex Web Apps with extremely
                       high traffic and critical performance
                       needs

                       devon@sparkred.com




Friday, March 16, 12                                                3


Been doing this for 14 years.
10MinuteMail handled a Slashdotting, front page listing on Yahoo
Tech, and front page Digg at the same time.
Worked on sites such as AT&T.com, People’s Choice Awards, Payless
Shoes, Vermont Country Store.
What is Performance?




Friday, March 16, 12                          4
Server-Side
                       Performance
                       •   Traffic Capacity

                           •   Request handling speed

                           •   Request handling
                               throughput

                       •   Lower CPU/memory/
                           bandwidth usage

                       •   Scalability




Friday, March 16, 12                                    5
Client-Side
                                      Performance
                                       •   Page Load Time

                                           •   First draw

                                           •   Inter-actable

                                           •   Complete

                                       •   Page Interaction
                                           Responsiveness

                                       •   Time to Complete Use Case




Friday, March 16, 12                                                   6


When a user sees the page start loading, to when they can do stuff,
to when the browser’s loading animation is done.
Use Ajax to pre-populate fields, type-ahead, real-time field
validation, reduce the number of full page submits/requests.

Solving for client side performance can have a dramatic impact on
the server side performance. Cached assets draw pages faster AND
reduce requests the server has to handle.
These two are TIED
                       •   Browser caching of static assets reduces page load
                           time AND reduces the number of requests the server
                           has to handle for the same number of page views

                       •   AJAX requests can typically be handled with far fewer
                           resources than full page requests

                       •   Reduced asset sizes means less bandwidth used and
                           shorter request response sending times



                       •   Solving for the Client brings Server performance gains!




Friday, March 16, 12                                                                 7


In engine building they say “Build for torque and the horsepower will
follow”
Why Should I Care?




Friday, March 16, 12                        8
Everyone Wins!
                       •   Client-Side Performance means

                           •   happier users

                           •   increased conversions

                           •   increased SEO ranking

                       •   Server-Side Performance means

                           •   more capacity on same hardware

                           •   saves money

                           •   scaling is easier




Friday, March 16, 12                                            9
Increased Conversions

                       •   +100 ms of page load time = 1% drop in sales



                       •   +500 ms of page load time = 20% drop in searches



                       •   +400 ms of page load time = 5-9% increase in clicking
                           “back” button before the page finished loading




Friday, March 16, 12                                                               10


We’ve all seen these stats, but they’re worth repeating. This isn’t
ivory tower stuff, this is simple business.
Why Apache?




Friday, March 16, 12                 11
Why I Use Apache
                       •   Popular web server - it’s everywhere

                       •   Easy to install, troubleshoot, and find information on

                       •   Mature and stable

                       •   Lots of extensions

                       •   Enterprise support requirements

                       •   It Is fast enough to max out your hardware!




Friday, March 16, 12                                                               12


Why not nginx (engine-X), Lighttpd, etc...?
Extensions like mod_pagespeed, mod_cluster, and more.
CPU Util @ 930 Mbit/sec
                         http://www.webperformance.com/load-testing/blog/2011/11/what-is-the-fastest-webserver/

Friday, March 16, 12                                                                                              13
iftop output - 613 Mbit/sec
                                                     PCA Awards
                                                     •   Saw 4x the planned for
                                                         traffic during spikes

                                                     •   140,000+ pages/minute -
                                                         2,333 pps (2012)

                                                     •   3,000+ Mbit/sec (2011)

                                                     •   1,200+ Mbit/sec PLUS
                                                         Akamai CDN offloaded traffic
                                                         (2012)

                                                     •   The site stayed up and was
                                                         quick to load and responsive
                                                         to interact with the whole
                                                         time




Friday, March 16, 12                                                                    14
Puppies
Friday, March 16, 12             15
Basic Apache Configs




Friday, March 16, 12                                                 16


The problem with Apache configs are that the defaults are typically
extremely out of date and based on much older hardware, network
bandwidth, browser abilities, and application complexity
Every App
                            is
                        Different



Friday, March 16, 12                17
Which MPM?
                       •   Worker MPM scales for high traffic without running out
                           of memory better

                       •   Less time spent tuning worker configs

                       •   Unless you’re still using non-threadsafe Apache code
                           (some PHP, etc..)

                       •   New in Apache 2.4 is the Event MPM




Friday, March 16, 12                                                               18


Limited testing I did with Event MPM shows it’s ~5% faster than
Worker, without real tuning.
MPM Worker Configs
                       Default                   Mine
                       <IfModule worker.c>       <IfModule worker.c>
                         StartServers        2     ThreadLimit 	      100
                         MaxClients        150     StartServers         5
                         MinSpareThreads    25     MaxClients        5500
                         MaxSpareThreads    75     ServerLimit	    	  200
                         ThreadsPerChild    25     MinSpareThreads    100
                         MaxRequestsPerChild 0     MaxSpareThreads 1000
                       </IfModule>                 ThreadsPerChild    100
                                                   MaxRequestsPerChild 0
                                                 </IfModule>




Friday, March 16, 12                                                        19


Just set it and forget it.
If you have memory leak issues, set MaxRequestsPerChild to
something like 5,000.
ab with small file
                              Version         Apache 2.2.3 MPM Worker

                          Document Size              119 bytes

                         Concurrency Level             1,000

                           Total Requests            100,000

                        Requests Per Second          20,790 r/s

                            Throughput              8,077 kb/s



                        hex core X5675



Friday, March 16, 12                                                    20
ab with large file
                              Version         Apache 2.2.3 MPM Worker

                          Document Size            95,002 bytes

                         Concurrency Level             1,000

                           Total Requests            100,000

                        Requests Per Second          1,258 r/s

                            Throughput             119,966 kb/s



                        hex core X5675



Friday, March 16, 12                                                    21
Linux Kernel Configs
                        net.ipv4.tcp_max_syn_backlog=30000
                        net.core.netdev_max_backlog=1200
                        net.ipv4.tcp_timestamps=0

                        net.ipv4.tcp_sack=0
                        net.ipv4.tcp_window_scaling=0
                        net.ipv4.tcp_max_tw_buckets=2000000
                        net.ipv4.tcp_mem=100000000 100000000 100000000

                        net.ipv4.tcp_wmem=100000000 100000000 100000000
                        net.ipv4.tcp_rmem=30000000 30000000 30000000
                        net.ipv4.ip_conntrack_max = 231072




Friday, March 16, 12                                                      22


This last setting (or larger) will keep your kernel from dropping
incoming connections under high load
Keepalive - On or Off?
                       •   reduces overhead of establishing new connections for
                           each request from the browser

                       •   can waste memory and other resources if left open too
                           long

                       •   Common practice is to disable them

                       •   I turn keepalive on, set to 6 seconds or 500 requests

                       •   For CDNs like Akamai, you’ll want to turn up the time to
                           more like 120 seconds




Friday, March 16, 12                                                                  23


Defaults are On, 15 seconds (too long), 100 requests (too small)
GZip - mod_deflate
                       •   gzip compressing text resources - html, js, xml, css
                           dramatically decreases the size of the response for those
                           assets: often up to 90% reduction in size

                       •   reduces transfer time, especially for clients with slower
                           connections (or big files)

                       •   This decreases page load time (Client) and reduces the
                           time the server thread is sending the response (Server)
                           # Removing Hosts vary
                           Header unset Vary
                           <IfModule mod_deflate.c>
                           	     AddOutputFilterByType DEFLATE text/html text/plain text/xml
                           text/css application/x-javascript
                           	     BrowserMatch ^Mozilla/4 gzip-only-text/html
                           	     BrowserMatch ^Mozilla/4.0[678] no-gzip
                           	     BrowserMatch bMSIE !no-gzip !gzip-only-text/html
                           </IfModule>




Friday, March 16, 12                                                                           24
Browser Caching
                       •   Tell the browser to cache all static assets, for as long as
                           you can bear it

                       •   Set the ETag

                       •   Set cache control and expiration response headers
                           <LocationMatch '^/pca/images/.*'>
                           	    FileETag MTime Size
                           	    Header set Cache-Control "max-age=2764800, public"
                           	    <IfModule mod_expires.c>
                           	    	     ExpiresActive On
                           	    	     ExpiresByType image/jpg A2764800
                           	    	     ExpiresByType image/jpeg A2764800
                               ExpiresByType image/png A2764800
                           	    </IfModule>
                           </LocationMatch>




Friday, March 16, 12                                                                     25


This is HUGE! You can reduce the number of HTTP requests you
have to handle by an order of magnitude or two by setting good
cache headers.
Disk Caching
                       •   Why not use mod_mem_cache?

                       •   Transparent web server caching of assets reduces load
                           without deployment and development complexities

                       •   Some warnings!

                           •    Doesn’t auto clean itself

                           •    Can grow to be huge if you don’t check the
                                headers being cached

                           •    Can grow to be huge if you have dynamic URI
                                content - blah.jpg;jsessionid=foo

                           •    Another place to purge cache for changed files




Friday, March 16, 12                                                               26


Mod_mem_cache has some bad bugs. mod_disk_cache lets the
kernel’s in memory file caching algorithm do all the heavy lifting
without tuning or exhausting available memory.
For 3 tier environments, it’s common to have static assets that get
deployed to the web servers separately from the application itself.
This makes deployments more complex and error prone and makes
local dev environments much harder to keep up to date.
Seam and richfaces image tags insert jsessionid to URI, etc...
Disk Caching - Config
                        <IfModule mod_disk_cache.c>
                        	   CacheRoot /var/cache/mod_disk_cache
                             CacheDirLevels 2
                             CacheDirLength 1

                             CacheEnable disk /pca/img
                             CacheEnable disk /pca/flash
                             CacheEnable disk /pca/css
                             CacheEnable disk /pca/js
                             CacheEnable disk /pca/images
                             CacheMaxFileSize 200715200
                             CacheDefaultExpire 3600
                             CacheIgnoreHeaders Set-Cookie
                        </IfModule>




Friday, March 16, 12                                              27
Mod_PageSpeed
                       •   Open Source Apache Module
                       •   Lots and Lots of filters
                            • image compression
                            • combine js/css
                            • sprite images
                            • domain sharding
                            • etc...




Friday, March 16, 12                                                    28


I know a previous presentation was done on mod_pagespeed, so I
won’t dive too deeply into all of it’s features and configs. Trying to
optimize for performance can make dev more complicated.
packtag. pagespeed.
Three Tier
                                   •   SSL Termination
                                   •   Load Balancing
                                   •   Mod_proxy/mod_cluster
                                   •   Mod_Security




Friday, March 16, 12                                            29


Apache is key for 3-tier architectures. It provides significant
performance, security, and PCI compliance wins.
Big improvements in Mod_proxy_balancer with 2.4 (dynamic cluster,
session bleedoff, etc)
Building
                       Scalable
                       Clusters w/
                       Apache
                       •   VIP
                       •   heartbeat
                       •   haproxy
                       •   DNS LB
                            • simple round robin
                            • smart




Friday, March 16, 12                               30
Questions?




Friday, March 16, 12                31
Thank you!

                       devon@sparkred.com




Friday, March 16, 12                        32

More Related Content

What's hot

FastView acceleration overview
FastView acceleration overviewFastView acceleration overview
FastView acceleration overviewYaron_Radware
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile WebJames D Bloom
 
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...
Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...Gear6
 
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...George White
 
Introduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for CloudIntroduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for CloudGear6
 
Google App Engine, Groovy and Gaelyk presentation at the Paris JUG
Google App Engine, Groovy and Gaelyk presentation at the Paris JUGGoogle App Engine, Groovy and Gaelyk presentation at the Paris JUG
Google App Engine, Groovy and Gaelyk presentation at the Paris JUGGuillaume Laforge
 
Performance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesPerformance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesCurelet Marius
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile WebJames D Bloom
 
Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)strommen
 
High Performance Websites
High Performance WebsitesHigh Performance Websites
High Performance WebsitesAaron Grogg
 
jmp206 - Lotus Domino Web Services Jumpstart
jmp206 - Lotus Domino Web Services Jumpstartjmp206 - Lotus Domino Web Services Jumpstart
jmp206 - Lotus Domino Web Services JumpstartBill Buchan
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client PerformanceHerea Adrian
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best PracticesJames D Bloom
 
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Data
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes DataSHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Data
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Datapanagenda
 
Show104 buried treasure
Show104 buried treasureShow104 buried treasure
Show104 buried treasureMark Myers
 

What's hot (20)

Email
Email Email
Email
 
FastView acceleration overview
FastView acceleration overviewFastView acceleration overview
FastView acceleration overview
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile Web
 
Magee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance ItalianoMagee Dday2 Fixing App Performance Italiano
Magee Dday2 Fixing App Performance Italiano
 
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...
Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...Gear6 and Scaling Website Performance:  Caching Session and Profile Data with...
Gear6 and Scaling Website Performance: Caching Session and Profile Data with...
 
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
 
Introduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for CloudIntroduction to First Commercial Memcached Service for Cloud
Introduction to First Commercial Memcached Service for Cloud
 
Google App Engine, Groovy and Gaelyk presentation at the Paris JUG
Google App Engine, Groovy and Gaelyk presentation at the Paris JUGGoogle App Engine, Groovy and Gaelyk presentation at the Paris JUG
Google App Engine, Groovy and Gaelyk presentation at the Paris JUG
 
Performance Of Web Applications On Client Machines
Performance Of Web Applications On Client MachinesPerformance Of Web Applications On Client Machines
Performance Of Web Applications On Client Machines
 
High Performance Mobile Web
High Performance Mobile WebHigh Performance Mobile Web
High Performance Mobile Web
 
Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)Building Lightning Fast Websites (for Twin Cities .NET User Group)
Building Lightning Fast Websites (for Twin Cities .NET User Group)
 
High Performance Websites
High Performance WebsitesHigh Performance Websites
High Performance Websites
 
Amazon silk browser
Amazon silk browserAmazon silk browser
Amazon silk browser
 
L20 Scalability
L20 ScalabilityL20 Scalability
L20 Scalability
 
jmp206 - Lotus Domino Web Services Jumpstart
jmp206 - Lotus Domino Web Services Jumpstartjmp206 - Lotus Domino Web Services Jumpstart
jmp206 - Lotus Domino Web Services Jumpstart
 
Web Client Performance
Web Client PerformanceWeb Client Performance
Web Client Performance
 
Mobile Web Best Practices
Mobile Web Best PracticesMobile Web Best Practices
Mobile Web Best Practices
 
Drupal And The Non Profit Agency
Drupal And The Non Profit Agency  Drupal And The Non Profit Agency
Drupal And The Non Profit Agency
 
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Data
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes DataSHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Data
SHOW104 - Buried treasure: Finding the Hidden Gold in Lotus Notes Data
 
Show104 buried treasure
Show104 buried treasureShow104 buried treasure
Show104 buried treasure
 

Similar to Apache performance

Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data Platform
Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data PlatformDeploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data Platform
Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data PlatformRackspace
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceSpark::red
 
How MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesHow MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesMongoDB
 
My Web Performance Dirty Secrets
My Web Performance Dirty SecretsMy Web Performance Dirty Secrets
My Web Performance Dirty SecretsFred Beringer
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondSpike Brehm
 
Web Performance Internals explained for Developers and other stake holders.
Web Performance Internals explained for Developers and other stake holders.Web Performance Internals explained for Developers and other stake holders.
Web Performance Internals explained for Developers and other stake holders.Sreejesh Madonandy
 
ROMA User-Customizable NoSQL Database in Ruby
ROMA User-Customizable NoSQL Database in RubyROMA User-Customizable NoSQL Database in Ruby
ROMA User-Customizable NoSQL Database in RubyRakuten Group, Inc.
 
NoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesNoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesRonen Botzer
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimizationMassimo Iacolare
 
Webinar share point performance feb2016 slideshare
Webinar share point performance feb2016 slideshareWebinar share point performance feb2016 slideshare
Webinar share point performance feb2016 slideshareDynatrace
 
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...Joel Oleson
 
Caching In The Cloud
Caching In The CloudCaching In The Cloud
Caching In The CloudAlex Miller
 
Optimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confOptimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confMáté Nádasdi
 
Scalability vs. Performance
Scalability vs. PerformanceScalability vs. Performance
Scalability vs. PerformanceSergeyChernyshev
 
Akamai 如何幫您的客戶用網站賺錢 how to monetize your site
Akamai 如何幫您的客戶用網站賺錢 how to monetize your siteAkamai 如何幫您的客戶用網站賺錢 how to monetize your site
Akamai 如何幫您的客戶用網站賺錢 how to monetize your site零壹科技股份有限公司
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Serverswebhostingguy
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinJonathan Hochman
 
Make Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedMake Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedPromet Source
 
Cloud Foundry Japan Community Meetup
Cloud Foundry Japan Community MeetupCloud Foundry Japan Community Meetup
Cloud Foundry Japan Community MeetupPatrick Chanezon
 

Similar to Apache performance (20)

Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data Platform
Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data PlatformDeploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data Platform
Deploy Apache Spark™ on Rackspace OnMetal™ for Cloud Big Data Platform
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web Perormance
 
How MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesHow MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case Studies
 
My Web Performance Dirty Secrets
My Web Performance Dirty SecretsMy Web Performance Dirty Secrets
My Web Performance Dirty Secrets
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and Beyond
 
Web Performance Internals explained for Developers and other stake holders.
Web Performance Internals explained for Developers and other stake holders.Web Performance Internals explained for Developers and other stake holders.
Web Performance Internals explained for Developers and other stake holders.
 
ROMA User-Customizable NoSQL Database in Ruby
ROMA User-Customizable NoSQL Database in RubyROMA User-Customizable NoSQL Database in Ruby
ROMA User-Customizable NoSQL Database in Ruby
 
NoSQL in Real-time Architectures
NoSQL in Real-time ArchitecturesNoSQL in Real-time Architectures
NoSQL in Real-time Architectures
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
 
Webinar share point performance feb2016 slideshare
Webinar share point performance feb2016 slideshareWebinar share point performance feb2016 slideshare
Webinar share point performance feb2016 slideshare
 
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...
SharePoint Performance: Physical to Virtual to Microsoft Azure Cloud and Offi...
 
Caching In The Cloud
Caching In The CloudCaching In The Cloud
Caching In The Cloud
 
Optimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confOptimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 conf
 
Scalability vs. Performance
Scalability vs. PerformanceScalability vs. Performance
Scalability vs. Performance
 
Akamai 如何幫您的客戶用網站賺錢 how to monetize your site
Akamai 如何幫您的客戶用網站賺錢 how to monetize your siteAkamai 如何幫您的客戶用網站賺錢 how to monetize your site
Akamai 如何幫您的客戶用網站賺錢 how to monetize your site
 
Performance stack
Performance stackPerformance stack
Performance stack
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Servers
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites Win
 
Make Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speedMake Drupal Run Fast - increase page load speed
Make Drupal Run Fast - increase page load speed
 
Cloud Foundry Japan Community Meetup
Cloud Foundry Japan Community MeetupCloud Foundry Japan Community Meetup
Cloud Foundry Japan Community Meetup
 

Recently uploaded

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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

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)
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Apache performance

  • 1. Apache Web Performance Leveraging Apache to make your site fly Friday, March 16, 12 1
  • 2. Who am I? & Why would you listen to me? Friday, March 16, 12 2
  • 3. Devon Hillard Web Application Architect Built 10MinuteMail Run Spark::red, an enterprise eCommerce Hosting company Complex Web Apps with extremely high traffic and critical performance needs devon@sparkred.com Friday, March 16, 12 3 Been doing this for 14 years. 10MinuteMail handled a Slashdotting, front page listing on Yahoo Tech, and front page Digg at the same time. Worked on sites such as AT&T.com, People’s Choice Awards, Payless Shoes, Vermont Country Store.
  • 5. Server-Side Performance • Traffic Capacity • Request handling speed • Request handling throughput • Lower CPU/memory/ bandwidth usage • Scalability Friday, March 16, 12 5
  • 6. Client-Side Performance • Page Load Time • First draw • Inter-actable • Complete • Page Interaction Responsiveness • Time to Complete Use Case Friday, March 16, 12 6 When a user sees the page start loading, to when they can do stuff, to when the browser’s loading animation is done. Use Ajax to pre-populate fields, type-ahead, real-time field validation, reduce the number of full page submits/requests. Solving for client side performance can have a dramatic impact on the server side performance. Cached assets draw pages faster AND reduce requests the server has to handle.
  • 7. These two are TIED • Browser caching of static assets reduces page load time AND reduces the number of requests the server has to handle for the same number of page views • AJAX requests can typically be handled with far fewer resources than full page requests • Reduced asset sizes means less bandwidth used and shorter request response sending times • Solving for the Client brings Server performance gains! Friday, March 16, 12 7 In engine building they say “Build for torque and the horsepower will follow”
  • 8. Why Should I Care? Friday, March 16, 12 8
  • 9. Everyone Wins! • Client-Side Performance means • happier users • increased conversions • increased SEO ranking • Server-Side Performance means • more capacity on same hardware • saves money • scaling is easier Friday, March 16, 12 9
  • 10. Increased Conversions • +100 ms of page load time = 1% drop in sales • +500 ms of page load time = 20% drop in searches • +400 ms of page load time = 5-9% increase in clicking “back” button before the page finished loading Friday, March 16, 12 10 We’ve all seen these stats, but they’re worth repeating. This isn’t ivory tower stuff, this is simple business.
  • 12. Why I Use Apache • Popular web server - it’s everywhere • Easy to install, troubleshoot, and find information on • Mature and stable • Lots of extensions • Enterprise support requirements • It Is fast enough to max out your hardware! Friday, March 16, 12 12 Why not nginx (engine-X), Lighttpd, etc...? Extensions like mod_pagespeed, mod_cluster, and more.
  • 13. CPU Util @ 930 Mbit/sec http://www.webperformance.com/load-testing/blog/2011/11/what-is-the-fastest-webserver/ Friday, March 16, 12 13
  • 14. iftop output - 613 Mbit/sec PCA Awards • Saw 4x the planned for traffic during spikes • 140,000+ pages/minute - 2,333 pps (2012) • 3,000+ Mbit/sec (2011) • 1,200+ Mbit/sec PLUS Akamai CDN offloaded traffic (2012) • The site stayed up and was quick to load and responsive to interact with the whole time Friday, March 16, 12 14
  • 16. Basic Apache Configs Friday, March 16, 12 16 The problem with Apache configs are that the defaults are typically extremely out of date and based on much older hardware, network bandwidth, browser abilities, and application complexity
  • 17. Every App is Different Friday, March 16, 12 17
  • 18. Which MPM? • Worker MPM scales for high traffic without running out of memory better • Less time spent tuning worker configs • Unless you’re still using non-threadsafe Apache code (some PHP, etc..) • New in Apache 2.4 is the Event MPM Friday, March 16, 12 18 Limited testing I did with Event MPM shows it’s ~5% faster than Worker, without real tuning.
  • 19. MPM Worker Configs Default Mine <IfModule worker.c> <IfModule worker.c> StartServers 2 ThreadLimit 100 MaxClients 150 StartServers 5 MinSpareThreads 25 MaxClients 5500 MaxSpareThreads 75 ServerLimit 200 ThreadsPerChild 25 MinSpareThreads 100 MaxRequestsPerChild 0 MaxSpareThreads 1000 </IfModule> ThreadsPerChild 100 MaxRequestsPerChild 0 </IfModule> Friday, March 16, 12 19 Just set it and forget it. If you have memory leak issues, set MaxRequestsPerChild to something like 5,000.
  • 20. ab with small file Version Apache 2.2.3 MPM Worker Document Size 119 bytes Concurrency Level 1,000 Total Requests 100,000 Requests Per Second 20,790 r/s Throughput 8,077 kb/s hex core X5675 Friday, March 16, 12 20
  • 21. ab with large file Version Apache 2.2.3 MPM Worker Document Size 95,002 bytes Concurrency Level 1,000 Total Requests 100,000 Requests Per Second 1,258 r/s Throughput 119,966 kb/s hex core X5675 Friday, March 16, 12 21
  • 22. Linux Kernel Configs net.ipv4.tcp_max_syn_backlog=30000 net.core.netdev_max_backlog=1200 net.ipv4.tcp_timestamps=0 net.ipv4.tcp_sack=0 net.ipv4.tcp_window_scaling=0 net.ipv4.tcp_max_tw_buckets=2000000 net.ipv4.tcp_mem=100000000 100000000 100000000 net.ipv4.tcp_wmem=100000000 100000000 100000000 net.ipv4.tcp_rmem=30000000 30000000 30000000 net.ipv4.ip_conntrack_max = 231072 Friday, March 16, 12 22 This last setting (or larger) will keep your kernel from dropping incoming connections under high load
  • 23. Keepalive - On or Off? • reduces overhead of establishing new connections for each request from the browser • can waste memory and other resources if left open too long • Common practice is to disable them • I turn keepalive on, set to 6 seconds or 500 requests • For CDNs like Akamai, you’ll want to turn up the time to more like 120 seconds Friday, March 16, 12 23 Defaults are On, 15 seconds (too long), 100 requests (too small)
  • 24. GZip - mod_deflate • gzip compressing text resources - html, js, xml, css dramatically decreases the size of the response for those assets: often up to 90% reduction in size • reduces transfer time, especially for clients with slower connections (or big files) • This decreases page load time (Client) and reduces the time the server thread is sending the response (Server) # Removing Hosts vary Header unset Vary <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html </IfModule> Friday, March 16, 12 24
  • 25. Browser Caching • Tell the browser to cache all static assets, for as long as you can bear it • Set the ETag • Set cache control and expiration response headers <LocationMatch '^/pca/images/.*'> FileETag MTime Size Header set Cache-Control "max-age=2764800, public" <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg A2764800 ExpiresByType image/jpeg A2764800 ExpiresByType image/png A2764800 </IfModule> </LocationMatch> Friday, March 16, 12 25 This is HUGE! You can reduce the number of HTTP requests you have to handle by an order of magnitude or two by setting good cache headers.
  • 26. Disk Caching • Why not use mod_mem_cache? • Transparent web server caching of assets reduces load without deployment and development complexities • Some warnings! • Doesn’t auto clean itself • Can grow to be huge if you don’t check the headers being cached • Can grow to be huge if you have dynamic URI content - blah.jpg;jsessionid=foo • Another place to purge cache for changed files Friday, March 16, 12 26 Mod_mem_cache has some bad bugs. mod_disk_cache lets the kernel’s in memory file caching algorithm do all the heavy lifting without tuning or exhausting available memory. For 3 tier environments, it’s common to have static assets that get deployed to the web servers separately from the application itself. This makes deployments more complex and error prone and makes local dev environments much harder to keep up to date. Seam and richfaces image tags insert jsessionid to URI, etc...
  • 27. Disk Caching - Config <IfModule mod_disk_cache.c> CacheRoot /var/cache/mod_disk_cache CacheDirLevels 2 CacheDirLength 1 CacheEnable disk /pca/img CacheEnable disk /pca/flash CacheEnable disk /pca/css CacheEnable disk /pca/js CacheEnable disk /pca/images CacheMaxFileSize 200715200 CacheDefaultExpire 3600 CacheIgnoreHeaders Set-Cookie </IfModule> Friday, March 16, 12 27
  • 28. Mod_PageSpeed • Open Source Apache Module • Lots and Lots of filters • image compression • combine js/css • sprite images • domain sharding • etc... Friday, March 16, 12 28 I know a previous presentation was done on mod_pagespeed, so I won’t dive too deeply into all of it’s features and configs. Trying to optimize for performance can make dev more complicated. packtag. pagespeed.
  • 29. Three Tier • SSL Termination • Load Balancing • Mod_proxy/mod_cluster • Mod_Security Friday, March 16, 12 29 Apache is key for 3-tier architectures. It provides significant performance, security, and PCI compliance wins. Big improvements in Mod_proxy_balancer with 2.4 (dynamic cluster, session bleedoff, etc)
  • 30. Building Scalable Clusters w/ Apache • VIP • heartbeat • haproxy • DNS LB • simple round robin • smart Friday, March 16, 12 30
  • 32. Thank you! devon@sparkred.com Friday, March 16, 12 32