SlideShare a Scribd company logo
1 of 38
Apache Performance Tuning

        Part 2: Scaling Out

  Sander Temme <sander@temme.net>
Agenda
•   Introduction
•   Redundancy in Hardware
•   Building Out: Separate Tiers
•   Building Out: Load Balancing
•   Caching Content
•   Conclusion
Introduction
• Why do This?
  – Scalability (Oh my gosh, I’m so popular!)
  – Reliability (We need five nines!)
• Why NOT do This?
  – It costs money
Redundancy in Hardware
• Moving Parts Break
  –   Hard Disks
  –   Power Supplies
  –   Hard Disks
  –   Fans
  –   Hard Disks
• Buy High Quality Disks
  – Refurbished, OEM, Brand Name
  – Which has longer warranty?
  – Which is more reliable?
Server Configuration
• Mirror those Disks
  – Install the RAID utility
  – Have it warn you
  – RAID is no good if you don’t learn of
    failures!
• Redundant Power Supplies
  – On different circuits
Scaling Vertically
Scaling Vertically
• Move Services to Other Hosts
• Pros:
  – Less resource contention
  – Specialized hardware
  – Scale out tiers individually
• Cons:
  – Development/Deployment harder
  – More hosts to manage
Scaling Horizontally
Scaling Horizontally
•   Multiple servers per tier
•   All receive requests
•   All serve same content
•   Some arbitration scheme
Load Balancing Schemes
• DNS Tricks
• Peer Server Pools
  – Network Load Balancing (Win2k3)
  – Wackamole
• Load Balancing Appliance
  – Box from F5, Juniper, Cisco, Foundry, …
  – Linux Virtual Server
DNS Round-Robin
• Easy!
• Multiple A Records in DNS Zone File
• Not Smart:
  – DNS Lookups are cached
  – Load on Server
  – Server Outage
Example Zone File
scalingout.org. 86400   IN SOA ns.scalingout.org. sctemme.scalingout.org. (
           2006051401   ; Serial
           86400        ; refresh (1 day)
           7200         ; retry (2 hours)
           8640000      ; expire (10 days)
           86400 )      ; minimum (1 day)

scalingout.org.        IN       NS      bagheera.scalingout.org.

gw                IN        A        10.11.0.1
bagheera          IN        A        10.11.0.2

; ...

mail              IN        CNAME    bagheera
ns                IN        CNAME    bagheera

www               IN        A        10.11.0.113
                  IN        A        10.11.0.114
                  IN        A        10.11.0.115
Peer-based: NLB
• Windows 2000 Server Enterprise Ed.,
  Windows Server 2003
• Up to 32 hosts in cluster
• All hosts assume cluster IP, MAC
• NLB makes LB decision
  – Only one host gets to answer TCP
    handshake
• Should be application independent
Peer-based: Wackamole
• High Availability Solution
• When Host Fails
  – Other hosts take over its IP addresses
  – Distribute IP addresses among cluster
  – Every IP address reliably available
• No Load Balancing!
  – Use with RR DNS (or something)

      http://www.backhand.org/wackamole/
Load Balancing Device




Client      Internet
Load Balancing
• One Load Balancer
• Many Web Servers
• Choice of Balancing Schemes
  – Round-robin, Least Used, …
• Reliability
  – Heartbeats, unavailable servers don’t
    receive requests
• Feature War
Linux Virtual Server
• Free, Open Source, etc.
• IP Virtual Server module in kernel
• Lots of auxiliary modules
  – Like a box of Legos
  – May come with Your Distribution
• Do It Yourself

    http://www.linuxvirtualserver.org/
Example: mod_proxy_balancer
• New in Apache HTTP Server 2.2
• Part of mod_proxy
• Two Load Balancing Methods
  – By number of requests
  – By number of bytes
• Detects failed backends
Apache Configuration
Listen 80
LogLevel debug
TransferLog logs/access_log

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

ProxyPass / balancer://mycluster/
ProxyPassReverse / http://1.2.3.4:80
ProxyPassReverse / http://1.2.3.5:80

<Proxy balancer://mycluster>
  BalancerMember http://1.2.3.4:80
  BalancerMember http://1.2.3.5:80
</Proxy>
Example: Tomcat, mod_jk
• Apache + mod_jk
• Multiple Tomcat servers
• Balancer Worker
Apache Configuration
LoadModule jk_module /Volumes/Files/asf/httpd-r415210w/modules/mod_jk.so
JKMount /servlets-examples/* loadbalancer
JKMount /*.jsp loadbalancer
JkMount /jkmanager/* jkstatus
JKLogFile logs/jk_log
JKLogLevel debug
JKWorkerProperty worker.list=loadbalancer,jkstatus
JKWorkerProperty worker.tc1.port=15109
JKWorkerProperty worker.tc1.host=localhost
JKWorkerProperty worker.tc1.type=ajp13
JKWorkerProperty worker.tc1.lbfactor=1
JKWorkerProperty worker.tc2.port=15209
JKWorkerProperty worker.tc2.host=localhost
JKWorkerProperty worker.tc2.type=ajp13
JKWorkerProperty worker.tc2.lbfactor=1
JKWorkerProperty worker.tc3.port=15309
JKWorkerProperty worker.tc3.host=localhost
JKWorkerProperty worker.tc3.type=ajp13
JKWorkerProperty worker.tc3.lbfactor=1
JKWorkerProperty worker.loadbalancer.type=lb
JKWorkerProperty worker.loadbalancer.balance_workers=tc1, tc2, tc3
JKWorkerProperty worker.jkstatus.type=status
Tomcat Configuration
   • Put same content on all Tomcats
   • Edit conf/server.xml:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tc1">


   • jvmRoute must match jk worker
     name!
Problem: Session State
• HTTP is Stateless
• Apps use Sessions
  – Cookies
  – URL Encoding
• Session created on single server
  – Broken by Load Balancing
  – PHP: sessions stored on disk
Solutions: Session State
• “Sticky” routing on Load Balancer
• Store State in DB
• Put benign State in Cookie
  – But don’t trust the client too much
• Replicate Sessions on Back-end
Tomcat Session Replication
• Share HttpSession objects across
  instances
• One instance dies, session lives on
• Apache will route requests to other
  instance
• Uses IP Multicast
Session Replication Config
• Uncomment <Cluster> element in
  server.xml
• Put empty <distributable /> element in
  <web-app> element in web.xml
Caching Content
• Dynamic Content is Expensive
• Static Content Relatively Cheap
• Several Approaches:
  – Dynamic caching
  – Pre-rendering popular pages
    (index.rss…)




                                    27
mod_cache Configuration
<IfModule mod_cache.c>
<IfModule mod_disk_cache.c>

      CacheRoot /raid1/cacheroot
      CacheEnable disk /

      # A page modified 100 min. ago will expire in 10 min.
      CacheLastModifiedFactor .1
      # Always check again after 6 hours
      CacheMaxExpire 21600
</IfModule>

</IfModule>




                                                        28
Make Popular Pages Static
• RSS Feeds
• Popular catalog queries
• … (Check your access log)




                              29
Static Page Substitution
<Directory "/home/sctemme/inst/blog/httpd/htdocs">

    Options +Indexes

    Order allow,deny
    Allow from all

    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA]

</Directory>




                                                     30
Tuning the Database Tier
• Not my area (sorry)
• Give Money to Oracle Consultants
  – (or MySQL) (or …)
• Tip: Separate Read and Write
  Operations
  – Replicate from Write db to Read db
  – Read db data slightly stale
    • Does it matter?
Putting it All Together
                                Read-only




Internet




Client                         Write-only
Monitoring the Farm
• Monitor for outages
  – More boxes, more failure
  – HA can mask failures
• Monitor for performance
  – Utilization
  – Trends
Monitoring Solutions
• Nagios
  – Check services, hosts for outage
  – Highly configurable, extendable
  – Worth your time investment
• Ganglia
  – Monitor for performance
  – See Brad Nicholes’s session
Monitoring Caveats
• Takes Time, Effort
  – Highly flexible products
• You can’t fix it
  – If you don’t know it’s broken
• You can’t tune it
  – If you don’t know the bottlenecks
Conference Roadmap
• Monitoring 2.0 - Zenoss, the next level of IT
  management (Training)
• Apache Performance Tuning Part 1:
  Scaling Up
• Load-balancing with Apache HTTPD 2.2
  and later
• Scaling the download infrastructure with
  your success
• Break My Site
Current Version

http://people.apache.org/~sctemme/ApconEU2008/
Thank You

More Related Content

What's hot

Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Servermohamedmoharam
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationTomcat Expert
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatEgnyte
 
[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at NuxeoNuxeo
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh thingsMarcus Deglos
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationTomasz Rękawek
 
Tomcat configuration
Tomcat configurationTomcat configuration
Tomcat configurationDima Gomaa
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikEdgar Espina
 
Tomcat New Evolution
Tomcat New EvolutionTomcat New Evolution
Tomcat New EvolutionAllan Huang
 
Introduction of Tomcat
Introduction of TomcatIntroduction of Tomcat
Introduction of TomcatDebashis Nath
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dumpejlp12
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 

What's hot (20)

Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
 
Apache Tomcat 8 Application Server
Apache Tomcat 8 Application ServerApache Tomcat 8 Application Server
Apache Tomcat 8 Application Server
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 Presentation
 
Tomcat next
Tomcat nextTomcat next
Tomcat next
 
How to monitor and manage Apache Tomcat
How to monitor and manage Apache TomcatHow to monitor and manage Apache Tomcat
How to monitor and manage Apache Tomcat
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
Apache TomEE - Tomcat with a kick
Apache TomEE  - Tomcat with a kickApache TomEE  - Tomcat with a kick
Apache TomEE - Tomcat with a kick
 
[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo[NYC Meetup] Docker at Nuxeo
[NYC Meetup] Docker at Nuxeo
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh things
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migration
 
Aem maintenance
Aem maintenanceAem maintenance
Aem maintenance
 
Auxiliary : Tomcat
Auxiliary : TomcatAuxiliary : Tomcat
Auxiliary : Tomcat
 
Tomcat configuration
Tomcat configurationTomcat configuration
Tomcat configuration
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip Hanik
 
Tomcat New Evolution
Tomcat New EvolutionTomcat New Evolution
Tomcat New Evolution
 
Introduction of Tomcat
Introduction of TomcatIntroduction of Tomcat
Introduction of Tomcat
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dump
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
What's New in WildFly 9?
What's New in WildFly 9?What's New in WildFly 9?
What's New in WildFly 9?
 
are available here
are available hereare available here
are available here
 

Similar to Apache Performance Tuning: Scaling Out

Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance_Out.pptx
Performance_Out.pptxPerformance_Out.pptx
Performance_Out.pptxsanjanabal
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Performance out
Performance outPerformance out
Performance outJack Huang
 
Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18Pascal benois performance_troubleshooting-spsbe18
Pascal benois performance_troubleshooting-spsbe18BIWUG
 
Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsLetsConnect
 
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...VMworld
 
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best Practices
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best PracticesVMworld 2014: Advanced SQL Server on vSphere Techniques and Best Practices
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best PracticesVMworld
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool ManagementBIOVIA
 

Similar to Apache Performance Tuning: Scaling Out (20)

Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance_Out.pptx
Performance_Out.pptxPerformance_Out.pptx
Performance_Out.pptx
 
2 7
2 72 7
2 7
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
title
titletitle
title
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
Performance out
Performance outPerformance out
Performance out
 
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
 
Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM Connections
 
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...
VMworld Europe 2014: Advanced SQL Server on vSphere Techniques and Best Pract...
 
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best Practices
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best PracticesVMworld 2014: Advanced SQL Server on vSphere Techniques and Best Practices
VMworld 2014: Advanced SQL Server on vSphere Techniques and Best Practices
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management
 

Recently uploaded

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
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
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
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
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
 
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
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
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
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

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
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
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
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 
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)
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
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
 
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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Apache Performance Tuning: Scaling Out

  • 1. Apache Performance Tuning Part 2: Scaling Out Sander Temme <sander@temme.net>
  • 2. Agenda • Introduction • Redundancy in Hardware • Building Out: Separate Tiers • Building Out: Load Balancing • Caching Content • Conclusion
  • 3. Introduction • Why do This? – Scalability (Oh my gosh, I’m so popular!) – Reliability (We need five nines!) • Why NOT do This? – It costs money
  • 4. Redundancy in Hardware • Moving Parts Break – Hard Disks – Power Supplies – Hard Disks – Fans – Hard Disks • Buy High Quality Disks – Refurbished, OEM, Brand Name – Which has longer warranty? – Which is more reliable?
  • 5. Server Configuration • Mirror those Disks – Install the RAID utility – Have it warn you – RAID is no good if you don’t learn of failures! • Redundant Power Supplies – On different circuits
  • 7. Scaling Vertically • Move Services to Other Hosts • Pros: – Less resource contention – Specialized hardware – Scale out tiers individually • Cons: – Development/Deployment harder – More hosts to manage
  • 9. Scaling Horizontally • Multiple servers per tier • All receive requests • All serve same content • Some arbitration scheme
  • 10. Load Balancing Schemes • DNS Tricks • Peer Server Pools – Network Load Balancing (Win2k3) – Wackamole • Load Balancing Appliance – Box from F5, Juniper, Cisco, Foundry, … – Linux Virtual Server
  • 11. DNS Round-Robin • Easy! • Multiple A Records in DNS Zone File • Not Smart: – DNS Lookups are cached – Load on Server – Server Outage
  • 12. Example Zone File scalingout.org. 86400 IN SOA ns.scalingout.org. sctemme.scalingout.org. ( 2006051401 ; Serial 86400 ; refresh (1 day) 7200 ; retry (2 hours) 8640000 ; expire (10 days) 86400 ) ; minimum (1 day) scalingout.org. IN NS bagheera.scalingout.org. gw IN A 10.11.0.1 bagheera IN A 10.11.0.2 ; ... mail IN CNAME bagheera ns IN CNAME bagheera www IN A 10.11.0.113 IN A 10.11.0.114 IN A 10.11.0.115
  • 13. Peer-based: NLB • Windows 2000 Server Enterprise Ed., Windows Server 2003 • Up to 32 hosts in cluster • All hosts assume cluster IP, MAC • NLB makes LB decision – Only one host gets to answer TCP handshake • Should be application independent
  • 14. Peer-based: Wackamole • High Availability Solution • When Host Fails – Other hosts take over its IP addresses – Distribute IP addresses among cluster – Every IP address reliably available • No Load Balancing! – Use with RR DNS (or something) http://www.backhand.org/wackamole/
  • 16. Load Balancing • One Load Balancer • Many Web Servers • Choice of Balancing Schemes – Round-robin, Least Used, … • Reliability – Heartbeats, unavailable servers don’t receive requests • Feature War
  • 17. Linux Virtual Server • Free, Open Source, etc. • IP Virtual Server module in kernel • Lots of auxiliary modules – Like a box of Legos – May come with Your Distribution • Do It Yourself http://www.linuxvirtualserver.org/
  • 18. Example: mod_proxy_balancer • New in Apache HTTP Server 2.2 • Part of mod_proxy • Two Load Balancing Methods – By number of requests – By number of bytes • Detects failed backends
  • 19. Apache Configuration Listen 80 LogLevel debug TransferLog logs/access_log LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so ProxyPass / balancer://mycluster/ ProxyPassReverse / http://1.2.3.4:80 ProxyPassReverse / http://1.2.3.5:80 <Proxy balancer://mycluster> BalancerMember http://1.2.3.4:80 BalancerMember http://1.2.3.5:80 </Proxy>
  • 20. Example: Tomcat, mod_jk • Apache + mod_jk • Multiple Tomcat servers • Balancer Worker
  • 21. Apache Configuration LoadModule jk_module /Volumes/Files/asf/httpd-r415210w/modules/mod_jk.so JKMount /servlets-examples/* loadbalancer JKMount /*.jsp loadbalancer JkMount /jkmanager/* jkstatus JKLogFile logs/jk_log JKLogLevel debug JKWorkerProperty worker.list=loadbalancer,jkstatus JKWorkerProperty worker.tc1.port=15109 JKWorkerProperty worker.tc1.host=localhost JKWorkerProperty worker.tc1.type=ajp13 JKWorkerProperty worker.tc1.lbfactor=1 JKWorkerProperty worker.tc2.port=15209 JKWorkerProperty worker.tc2.host=localhost JKWorkerProperty worker.tc2.type=ajp13 JKWorkerProperty worker.tc2.lbfactor=1 JKWorkerProperty worker.tc3.port=15309 JKWorkerProperty worker.tc3.host=localhost JKWorkerProperty worker.tc3.type=ajp13 JKWorkerProperty worker.tc3.lbfactor=1 JKWorkerProperty worker.loadbalancer.type=lb JKWorkerProperty worker.loadbalancer.balance_workers=tc1, tc2, tc3 JKWorkerProperty worker.jkstatus.type=status
  • 22. Tomcat Configuration • Put same content on all Tomcats • Edit conf/server.xml: <Engine name="Catalina" defaultHost="localhost" jvmRoute="tc1"> • jvmRoute must match jk worker name!
  • 23. Problem: Session State • HTTP is Stateless • Apps use Sessions – Cookies – URL Encoding • Session created on single server – Broken by Load Balancing – PHP: sessions stored on disk
  • 24. Solutions: Session State • “Sticky” routing on Load Balancer • Store State in DB • Put benign State in Cookie – But don’t trust the client too much • Replicate Sessions on Back-end
  • 25. Tomcat Session Replication • Share HttpSession objects across instances • One instance dies, session lives on • Apache will route requests to other instance • Uses IP Multicast
  • 26. Session Replication Config • Uncomment <Cluster> element in server.xml • Put empty <distributable /> element in <web-app> element in web.xml
  • 27. Caching Content • Dynamic Content is Expensive • Static Content Relatively Cheap • Several Approaches: – Dynamic caching – Pre-rendering popular pages (index.rss…) 27
  • 28. mod_cache Configuration <IfModule mod_cache.c> <IfModule mod_disk_cache.c> CacheRoot /raid1/cacheroot CacheEnable disk / # A page modified 100 min. ago will expire in 10 min. CacheLastModifiedFactor .1 # Always check again after 6 hours CacheMaxExpire 21600 </IfModule> </IfModule> 28
  • 29. Make Popular Pages Static • RSS Feeds • Popular catalog queries • … (Check your access log) 29
  • 30. Static Page Substitution <Directory "/home/sctemme/inst/blog/httpd/htdocs"> Options +Indexes Order allow,deny Allow from all RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /cgi-bin/blosxom.cgi/$1 [L,QSA] </Directory> 30
  • 31. Tuning the Database Tier • Not my area (sorry) • Give Money to Oracle Consultants – (or MySQL) (or …) • Tip: Separate Read and Write Operations – Replicate from Write db to Read db – Read db data slightly stale • Does it matter?
  • 32. Putting it All Together Read-only Internet Client Write-only
  • 33. Monitoring the Farm • Monitor for outages – More boxes, more failure – HA can mask failures • Monitor for performance – Utilization – Trends
  • 34. Monitoring Solutions • Nagios – Check services, hosts for outage – Highly configurable, extendable – Worth your time investment • Ganglia – Monitor for performance – See Brad Nicholes’s session
  • 35. Monitoring Caveats • Takes Time, Effort – Highly flexible products • You can’t fix it – If you don’t know it’s broken • You can’t tune it – If you don’t know the bottlenecks
  • 36. Conference Roadmap • Monitoring 2.0 - Zenoss, the next level of IT management (Training) • Apache Performance Tuning Part 1: Scaling Up • Load-balancing with Apache HTTPD 2.2 and later • Scaling the download infrastructure with your success • Break My Site