Per e f r o f r o m r a m n a c n e e & Scal ca ab a i b lity t Andy Thornton



Similar documents
making drupal run fast

Drupal Performance Tuning

Ensuring scalability and performance with Drupal as your audience grows

The importance of Drupal Cache. Luis F. Ribeiro Ci&T Inc. 2013

Optimizing your Magento store for heavy API access. 1.0 June 2013

E-commerce is also about

WordPress Optimization

Simple Tips to Improve Drupal Performance: No Coding Required. By Erik Webb, Senior Technical Consultant, Acquia

MAGENTO HOSTING Progressive Server Performance Improvements

Performance for Site Builders

Web Performance. Sergey Chernyshev. March '09 New York Web Standards Meetup. New York, NY. March 19 th, 2009

(An) Optimal Drupal 7 Module Configuration for Site Performance JOE PRICE

Accelerating Wordpress for Pagerank and Profit

Cache All The Things

Performance Tuning and Optimization for high traffic Drupal sites. Khalid Baheyeldin Drupal Camp, Toronto May 11 12, 2007

Site Audit ( /site_audit) Generated on Fri, 22 Aug :14:

Drupal in the Cloud. by Azhan Founder/Director S & A Solutions

Speed up your web site. Alan Seiden Consulting alanseiden.com

4x High Performance for Drupal. Presented by Fabian Franz. Step by Step

5 Mistakes to Avoid on Your Drupal Website

Drupal Performance Tips and Tricks. Khalid Baheyeldin. Drupal Camp Toronto 2014

Magento & Zend Benchmarks Version 1.2, 1.3 (with & without Flat Catalogs)

Wednesday, October 10, 12. Running a High Performance LAMP stack on a $20 Virtual Server

OVERVIEW Methodology Objectives Terminology Recommended Test Protocol... 3 CLOUD SERVICES VS. DEDICATED HOSTING...

Auditing Drupal sites for performance, content and optimal configuration

Nginx 1 Web Server Implementation

9 Tried and Tested Tips to Increase the Power of your Magento Store

Igor Seletskiy. CEO, CloudLinux

PHP web serving study Performance report

Contents of the document

Loudon & Company. Better Decision-Making:! Drupal Performance

Layers of Caching: Key to scaling your website. Lance Albertson -- Narayan Newton

79 Tips and Tricks for Magento Performance Improvement. for Magento Performance Improvement

Common Server Setups For Your Web Application - Part II

Optimizing Drupal Performance. Benchmark Results

How To Use Ngnix (Php) With A Php-Fpm (Php-Fmm) On A Web Server (Php5) On Your Web Browser) On An Ubuntu Web Server On A Raspberry Web 2.5 (Net

Designing, Scoping, and Configuring Scalable Drupal Infrastructure. Presented by David Strauss

Varnish the Drupal way

How does Drupal 7 Work? Tess Flynn, KDØPQK

Magento Performance Optimization Whitepaper

PHP on IBM i: What s New with Zend Server 5 for IBM i

A 100k Users.. Now What?

1 How to Monitor Performance

Performance Optimization For Operational Risk Management Application On Azure Platform

Acquia Introduction December 9th, 2009

Installing an open source version of MateCat

Bubble Full Page Cache for Magento

AUDIT REPORT EXAMPLE

HOW TO MAKE WP FLY...

MySQL Enterprise Monitor

Web Performance First Aid. Alan Seiden Consulting alanseiden.com

W3Perl A free logfile analyzer

Practical Load Balancing

Rails Application Deployment. July Philly on Rails

Bubble Full Page Cache for Magento

IT Best Practices Audit TCS offers a wide range of IT Best Practices Audit content covering 15 subjects and over 2200 topics, including:

SharePoint 2010 Performance and Capacity Planning Best Practices

Linux Tools for Monitoring and Performance. Khalid Baheyeldin November 2009 KWLUG

Enterprise Edition Scalability. ecommerce Framework Built to Scale Reading Time: 10 minutes

WompMobile Technical FAQ

Web Performance. Lab. Bases de Dados e Aplicações Web MIEIC, FEUP 2014/15. Sérgio Nunes

DevShop. Drupal Infrastructure in a Box. Jon Pugh CEO, Founder ThinkDrop Consulting Brooklyn NY

Elle Décor Lookbook ipad Application

Bring your intranet to the IBM i With Drupal and Zend Server

PHP PERFORMANCE. Principles and Tools. By Kevin Schroeder Technical Consultant Zend Technologies. Copyright 2007, Zend Technologies Inc.

Cognos Performance Troubleshooting

Website Performance: Kyle Simpson

The Devil is in the Details. How to Optimize Magento Hosting to Increase Online Sales

HOW TO BUILD A VMWARE APPLIANCE: A CASE STUDY

Server Architecture for High- Performance Drupal

Creating Value through Innovation MAGENTO 1.X TO MAGENTO 2.0 MIGRATION

Making Sense of the Numbers DOs and DON'Ts of Quality Performance Testing

Sawmill Documentation Technical Manual FAQ User Guide WWW Sawmill

Are You Ready for the Holiday Rush?

1 How to Monitor Performance

Brace for 2012 Christoph

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

How to Configure edgebox as a Web Server

Drupal 6 to Drupal 7 Migration Worksheet

How To Configure Apa Web Server For High Performance

Achieving High Throughput. Fernando Castano Sun Microsystems

A BASELINE FOR WEB PERFORMANCE WITH PHANTOMJS

Installing Apache, MySQL, PHP, and PECL on Windows

by

Advanced performance optimizations. By Peter Elmered

Abstract. 1. Introduction

Scalability and Performance with Apache 2.0

Apache2 Configuration under Debian GNU/Linux. Apache2 Configuration under Debian GNU/Linux

Drupal CMS for marketing sites

Introduction. Just So You Know... PCI Can Be Difficult

Digital Downloads Pro

Website Optimization Tips for Speed

WHITE PAPER. Domo Advanced Architecture

Table of Contents. Overview... 1 Introduction... 2 Common Architectures Technical Challenges with Magento ChinaNetCloud's Experience...

Drupal Memcached Nginx

LoadRunner and Performance Center v11.52 Technical Awareness Webinar Training

ANALYSING SERVER LOG FILE USING WEB LOG EXPERT IN WEB DATA MINING

EXECUTIVE SUMMARY CONTENTS. 1. Summary 2. Objectives 3. Methodology and Approach 4. Results 5. Next Steps 6. Glossary 7. Appendix. 1.

Getting Started with AWS. Hosting a Static Website

Front-End Performance Testing and Optimization

Transcription:

Performance & Scalability Andy Thornton

An opening Apology This is my apology for making my slideshow very text heavy... However, I added some fun pictures, to hopefully compensate... And yes, these slides will be available for download.

Who's this presentation for?

Agenda Capacity Planning and Architecture Testing Tools Pressflow & Varnish Where are the pinch points? PHP Caching MySQL Apache Drupal Tweaks Handy Tools Further Reading Questions?

Capacity Planning Determine Metrics»Test Plan»Analyse Results»Rinse and repeat However Beautiful the strategy, you should occasionally look at the results - Winston Churchill

Testing Tools The Grinder A java based load testing tool. http://grinder.sourceforge.net/ JMeter Java based tool, designed to load test functional behavior and measure performance. http://jakarta.apache.org/jmeter/ XHProf Profiler for PHP providing some valuable metrics and reporting. http://mirror.facebook.net/facebook/xhprof/doc.html Openload http://www.opendemand.com/openload/ Soasta Leveraging resources from the cloud, Soasta is fast becoming a leader in performance testing. (Acquia Partner) http://www.soasta.com/ RRD Tool OpenSource high performance data logging and graphing system for time series data. http://www.mrtg.org/rrdtool/

Acquia & Soasta CloudTest Dashboard

Drupal Distribution Optimised for performance and scale Support for database replication Support for Squid or Varnish as reverse proxy caches Optimised for MySQL Optimised for PHP Supported by Acquia Varnish Varnish stores web pages in memory so the web servers don't have to create the same web page over and over again. The web server only recreates a page when it is changed. Reporting from Varnish can provide some good data to help with capacity planning.

Investigating Issues Memory Tapped Out? Apache is generally the culprit, fine tune your config and possibly add more memory. CPU is maxing out? PHP is your prime suspect as it's CPU intensive, look into using an Opcode cache. Hard Drives are getting Thrashed! Take a look at MySQL, enabling the query cache may help. Fine tune your queries.

Pain points? Apache MySQL PHP

PHP parses and compiles all code into an intermediary series of opcodes, or more accurately an intermediary series of opcodes for each request. Accelerators (Opcode Caching) Alternative PHP Cache (APC) eaccelerator XCache Nusphere PhpExpress Zend Accelerator Application Profiling Some applications work well on small scale sites, but get bogged down when moved into production. Zend Studio Komodo Eclipse (PDT) Xdebug Aptanta Studio Application Processes Creating new processes is a slow operation. CGI applications that fork a new process on every invocation will run substantially slower the more processes are running. Running PHP in multi-threaded mode can improve response times, but consider disabling unused services, for example: telnetd, inetd, atd, ftpd, lpd, sambad sendmail portmap xsf, windows manager, xinit, X

When Drupal Attacks! Sometimes, a cache setup can slow things down! Tip 1: If APC is compiled with mmap support, you can use /dev/zero (usually the default) /dev/zero apc.mmap_file_mask = /dev/zero Andy will explain why /dev/zero is handy... Tip 2: Make sure to give it enough memory. Tip 2: Make sure to give it enough memory. Tip 3: Always measure and adjust as needed.

Andy's Page of Weird Apache Commands Display currently loaded modules apachectl -t -D DUMP_MODULES Good candidates to remove, mod_cgi, mod_dav, mod_ldap* How do I see if that made a difference? ab -n 100 -c 5 http://www.domain.com/test.html Is the swap file being used? vmstat 1 60 Runs vmstat every 1 second 60 times Decreasing Apache Timeouts Normally the default is set to 5 minutes (300 seconds), how about reducing it to 20 seconds? TimeOut 20 You can do this in your virtual host or server config.

Maxclients Setting in Apache Whats a good way to find the maxclients number? MaxClients (Ram - size of all other processes) / (size of the apache process) We are making an educated guess based on dividing the system memory (our physical RAM) by the maximum size of an apache process, with enough wiggle room to have the operating system run smoothly. To find the size of a running process; ps -ylc apache2 --sort:rss Divide the size by 1024 to get the process size in meg. You can also use pmap, use top to find the pid, then use; pmap -x <pid id> Another handy way of seeing how your memory is doing. free -m and good old VMSTAT to see if your memory is being paged vmstat 5 60

Huge List of Apache Tips mod_expires Allows Drupal to send out http expires headers caching all files in the users browsers (~2 weeks) or until a new page is made available. This is good for all static files / images / css / javascript. Drupal is pre-configured to use mod_exp if it's available. Configure it's use in your.htaccess # Cache files for 2 weeks after access ExpiresActive On ExpiresDefault A1209600 # Don't Cache Dynamic pages ExpiresByType text/html A1 You don't let Apache cache HTML content as Drupal's content isn't static. This is why Drupal uses it's own cache. Reduce DNS Lookups You can tell Apache to not perform a DNS lookup on files by their mime type. HostnameLookups Off <Files ~"\.(html/cgi)$"> HostnameLookup On </Files> File Negotiation Be specific when specifying filenames rather than wildcards (when possible). Instead of: DirectoryIndex index Use: DirectoryIndex index.cgi index.php

More Apache Tips... mod_deflate this allows your web server to compress files before being sending them to the users browser AddOutputFilterByType Deflate text/html text/css More advanced example: 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 htaccess If you have access to your VirtualHosts in Apache, move your directives out of htaccess and move them in to the VirtualHost for your website. The reason for this is that Apache loads your virtual host once when started but Drupal searches for htaccess files in multiple directories at runtime. Disable htaccess lookups with: <Directory /> AllowOveride None </Directory> # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif jpe?g png)$ no-gzip dont-vary

Webserver Apache supports pluggable concurrency modules, called Multi Processing Modules. So which is a good fit for my website? Worker Uses multiple child processes with many threads each. Each thread handles one connection at a time. Prefork Uses multiple child processes each with one connection at a time. On many systems it's comparable to worker (in speed) but it uses more memory. Generally, recommended for Drupal due to it's threading model. Alternatives to Apache Nginx (engine-x) Faster than Apache and has more predictable memory usage. Not as straight forward to setup (rewrite rules for example). LIGHTHTTPD Good performance. Although there has been discussion on the drupal forums as to its ability to cleanly run Drupal 7. Not for the feint of heart. Microsoft Web Matrix Runs Drupal under IIS with PHP, good for Microsoft shops. http://www.microsoft.com/web/drupal/

Database Optimisations Drupal does a lot of work in the database, especially for authenticated users and modules, so how can we get the best out of our database? Enable Query Cache This feature is generally disabled by default. To enable it, assign a value to query_cache_size in your mysql configuration file. [mysqld] query_cache_size = 64M You can query the setting as it's a variable. SHOW VARIABLES LIKE 'have_query_cache'; You may have to do some testing to find the best value to use. Logging Slow Queries You can instruct MySQL to log all queries that take too long to run, for later analysis. [mysqld] log_slow_queries=/var/log/slow-queries.log log_query_time=5 Leaving off the query time will default it to 10 seconds. Analysing Slow Queries Prepend your query with EXPLAIN and run it for more information, or analyse your query with MAATKIT. EXPLAIN will show which indices are being used, sometime just indexing the table can be a good fix.

More Database Tips Table locking can be a good indicator of problems in your database. MyISAM and InnoDb Performance wise, they both stand up well, but whats the difference for Drupal? Table Locking MyISAM = Table Level Locking InnoDB = Row level Locking How do I know if I need to make a change? Take a look at SHOW STATUS LIKE 'Table%'; Table_locks_immediate 1151552 Table_locks_waited 15324 How do I change a table type? Good Candidates for InnoDB Which tables would benefit from changing to use row level locking. Cache tables Watchdog Sessions Accesslog Tips mysqlreport can be automated to show any wait times for transactions. Keep your cron short to prune tables regularly if tables get too big. You can use the Devel module to identify Query expensive pages in Drupal. ALTER TABLE accesslog TYPE='InnoDB';

Drupal 6 Caching in Drupal can be enabled through the Performance module in Admin and settings.php. Drupal Ships with 6 Cache tables Drupal Performance Module Options cache Normal: Drupal bootstraps in phases, when normal is selected it uses just enough phases to load a page from cache. Keeping db queries to a minimum. cache_block cache_page cache_filter cache_menu cache_form Aggressive: Completely bypasses loading of all modules. Boot and Exit hooks are never called for cached pages. This means less PHP is parsed since no modules are loaded. There's are also fewer database calls. Fastpath: Not enabled from the admin panel, this option is enabled from settings.php. The idea is that a call to the file system is faster as there's no ramping up for a database query. This may not scale across load balanced hosting.. Developer Tip When writing your own modules and need to cache data, think about using your own tables. It reduces write contention with Drupal for using the cache tables and doesn't bloat the table with your data. Most functions also have a $reset parameter which instructs the function to clear down it's internal cache. Consolidate Javascript & CSS Enabling these options "smushes" javascript and stylesheets into single files and minifies them.

Drupal 6 Drupal doesn't store session information for the first anonymous visitor. This is so webcrawlers and spiders don't fill your session tables up. However, these tables can get very large. Pruning Sessions Garbage Collection Drupal controls when session start by turning off Default value for garbage collection is a little over 2 PHP's session autostart functionality in htaccess. days, you can also increase the frequency of collection with php_value session.auto_start 0 session.gc_maxlifetime (seconds) session.cache_expire (minutes) The session table is cleared out when PHP's garbage collection runs. The lifetime of a session record is determined by session.gc.maxlifetime (seconds) Other settings you can experiment with: session.cache_expire session.cache_limiter session.cookie_lifetime session.save_handler session.use_only_cookies session.use_trans_sid Note: When you adjust maxlifetime, adjust cache_expire to be the same. Tip: As Drupal can serve cached pages to anonymous users and anonymous users don't normally use interactive features of Drupal. How about reducing the time they are logged in or log them out when they close their browser. # 86400 seconds = 24 hours session.cookie_lifetime, 86400 # Logout on browser close session.cookie_lifetime, 0

Whats Changed in Drupal 7 Not a great deal has changed with Drupal 7, there's been a lot of code optimisation and some elements of Pressflow have made their way into the Drupal 7 codebase. However, the following changes are notable. Removed Caching Mode Option on the performance page Throttling Block throttling. New Features New Performance Logging Improved performance on uncached pages When logged in, performs fewer queries on path alias lookups Tighter Integration with APC

Alternatives to Search Google CSE Google's custom search service with some impressive features, including branding support and onthe-fly indexing support. Well documented API, but requires some work to get setup initially. http://www.google.com/cse/ Acquia Search Built upon Lucene and Solr from Apache, hosted service with easy integration with Drupal. All administration tasks are built in to the admin panel. A very powerful alternative to Drupal's built in search. http://acquia.com/products-services/acquia-search Apache Solr Java based open source enterprise search platform from the Apache Lucene project. http://lucene.apache.org/solr/

More Tweaks Theme Optimisation Use of sprite maps / minified code / Optimised Images / Google JSAPI / Browser Caching Expiring Content / Reduce HTTP requests / Non Blocking Javascript Throttling and Block Caching Enabling throttling allows you to turn off modules & blocks when the system starts to get sluggish. You can set the threshold in the admin panel, and determine which modules and blocks to turn off from their respective admin pages. Modules Cacherouter / Boost / Devel / Authcache Content Delivery Networks The capacity sum of strategically placed servers can result in an impressive boost in the number of concurrent users. Akamai Technologies Amazon CloudFront BitGravity CacheFly CD Networks Windows Azure

Handy Tools Web Load Testing & Page Audit http://www.webpagetest.org/ Open Source Testing Tools http://www.opensourcetesting.org/performance.php JMeter http://jakarta.apache.org/jmeter/ Apache Bench http://httpd.apache.org/docs/2.0/programs/ab.html mysqlreport http://hackmysql.com/mysqlreport YSlow (Firebug) http://developer.yahoo.com/yslow/ Performance Articles (Google Code) http://code.google.com/speed/articles/ Devel Module (Drupal) http://drupal.com/project/devel Ubuntu, Landscape http://www.canonical.com/enterpriseservices/landscape SOASTA CloudTest http://acquia.com/soasta/next-steps Client (browser based tools) Boomerang / Firebug / Chrome Dev Tools / MAATKIT http://www.maatkit.org/

Further Reading The Art Of Capacity Planning Web-based companies live or die by the ability to scale their infrastructure to accommodate increasing demand. This book is a hands-on and practical guide to planning for such growth. O'Reilley Media: Amazon High Performance MySQL High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. This book covers every aspect of MySQL performance in detail and focuses on robustness, security and data integrity. O'Reilley Media: Amazon Even Faster Websites Steve Sounders works on the performance team at Google and has written a couple of great books on performance. O'Reilley Media: Bio

Questions? Andy.Thornton@mediacurrent.com Slides will be made available on http://www.drupalatlanta.com/ after the presentation.