Your SlideShare is downloading. ×
Joomla! Performance on Steroids
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Joomla! Performance on Steroids

22,043
views

Published on

A Prresentation on Joomla! Performance. How to make your Joomla! site load faster, smoother and with little impact on the server.

A Prresentation on Joomla! Performance. How to make your Joomla! site load faster, smoother and with little impact on the server.

Published in: Technology

2 Comments
10 Likes
Statistics
Notes
  • @Александр Васильев Hello, thank you for your questions. I assume you mean servers with load balancers, database replication etc. By default we do not offer such configurations, but your could contact us directly at affiliates at siteground dot com and ask for a custom offer. Once we know what your specific requirements are, how well visited your site it, we will be able to evaluate your needs and make a custom offer. The SiteGround Team
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dear Tenko, dear Marian, thank you for very detailed explanation with examples! After such impressive overview I might ask only one question: do you provide a services for large-scale Joomla websites optimisation and migration to dedicated multy-servers?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
22,043
On Slideshare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
172
Comments
2
Likes
10
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. JOOMLA! PERFORMANCEON STEROIDSTenko NikolovSiteGround CEOMarian Marinov1H CEO
  • 2. DOUBLE SESSION
  • 3. HOW TO MAKE YOUR JOOMLA LOADFASTERLevel: Beginner to intermediatePresented by: TenkoPART 1
  • 4. SETUP JOOMLA FOR HIGH-PERFORMANCE(OR JOOMLA AND SERVER SIDE CACHING)Level: AdvancedPresented by: Tenko & MarianPART 2
  • 5. Ask usquestionsatanytime!INTERACTIVE SESSIONS
  • 6. A LITTLE BIT ABOUT US
  • 7. Tenko’s Bio 17+ years of IT life 8 years with SiteGround 7 years CEO at SiteGround Takes care of 80,000+ Joomla!s Husband, dad Passionate about photography &geeky toys Addicted to cars and everythingfast
  • 8. Marian’s Bio Sysadmin since 1996 CEO and Co-Founder of 1H Ltd. andmastermind behind 1H Hive Computer science teacher at SofiaUniversity since 2007 Coordinator of OpenFest (Bulgariasbiggest FOSS conference) since 2005 Regular speaker at FOSS conferencesin the Balkan region
  • 9.  Devs/Sysadmins who love to ssh and do everything ontheir own – cloud/vps/dedicated server owners Large/high traffic Joomla websites owners Multiple Joomla websites owners Performance GeeksWHO CARES ABOUTPERFORMANCE?
  • 10. EVERYONE!WHO SHOULD CARE?
  • 11.  Site speed affects your Google Rankings! Keep readers/customers happy & paying Be able to handle more visitors Go green and save $$$ from serversWHY CARE ABOUTPERFORMANCE
  • 12. Faster Joomla = OptimizationsKEEPCALMIT’S NOTROCKETSCIENCE
  • 13. PART 1Let’s get the basicsdone
  • 14.  Keep your Joomla! updated Choose extensions wisely Deactivate unused extensions, upgrade used Simplify your templates as much as possibleGENERAL GUIDELINES
  • 15. Simple Front Page Is Better Fancy stuff – only if you really need it Remove unnecessary large images Use fewer internal/external links – addsitemap Avoid loading content from remote servers
  • 16. APPLICATION LEVELOPTIMIZATIONS
  • 17. Enable Compression Natively supported by Joomla! – no extensions needed Requires mod_gzip/deflate to be enabled on the serverSiteGlobalConfigurationServer
  • 18. Enable Joomla! Cache Enable the “System – Cache” plugin
  • 19. Enable Joomla! CacheSiteGlobalConfigurationSystemCacheSettings
  • 20. Some .htaccess Magic Get the code:http://goo.gl/ze09B How it works:- Etag – Tells browsers that an image/unit does not need to bereloaded- Expires Headers – Set different expiration dates for various filetypes- AddOutputFilterByType DEFLATE – minifies the compiled HTMLsource code
  • 21. Some .htaccess Magic The code:FileETag MTime SizeAddOutputFilterByType DEFLATE text/html text/css application/javascriptExpiresActive OnExpiresDefault "now plus 1 hour"ExpiresByType text/css "now plus 1 week“ExpiresByType application/javascript "now plus 1 week"ExpiresByType application/x-javascript "now plus 1 week”
  • 22. More Optimizations: Images, CSS & JS Resize images – never upload 2560x1600 pictures Smush your images Minify and combine CSS and JS files Use image sprites
  • 23. Sounds Nice, How Do I Begin? Use smush.it Photoshop/Fireworks Joomla! Extensions
  • 24. Some Highly Rated Extensions JCH Optimize – Combines JS and CSS,Combines images in sprites, Minify and Compress Jbetolo – same as above but + CDN support JotCache – improves the Joomla! built in CoreCache Cache Cleaner – easily clean the cache from theJoomla! admin panel
  • 25. JCH Optimize Enable the “System – JCH Optimize” plugin
  • 26. JCH Optimize Settings
  • 27. Google mod_pagespeed An open-source Apache module - compress,combine and cache Needs to be installed/configured by a SystemAdministrator Available on SiteGround servers
  • 28. Check How’s Your Website Doing Google Page Speed Insights -http://goo.gl/zPkxx YSlow - http://goo.gl/qIios GTmetrix - http://gtmetrix.com/
  • 29. Some tests – Default Joomla!No Optimizations Cache/Compression.htaccess rulesJCHPage LoadTime1.61s 1.49s 1.32s 1.02sTotal PageSize563KB 162KB 162KB 151KBNumber ofRequests35 35 35 19PageSpeedGradeF (41%) B (65%)B(87%)A(91%)YSlowGradeC (70%) B (66%)B(86%)A(92%)
  • 30. SERVER LEVELOPTIMIZATIONS
  • 31. YOUR VISITORSLOCATIONMATTERS!USE CDN
  • 32. CDN Features CDN will make your website faster CDN will help avoid unneeded I/O on your harddrives CDN will appeal to both Google and your visitors
  • 33. Opcode/Object Caching FastCGI + APC PHP extension Memcached and PHP/MySQL eAccelerator
  • 34. Joomla Interaction with YourDatabase First request goes tothe database server
  • 35. Object Caching First request goes tothe database server Objects are alsostored in Memcached
  • 36. Object Caching All consecutiverequests areforwarded to theMemcached server
  • 37. How PHP works Scanning Lexing Parsing Compilation Opcode Execution
  • 38.  Opcode  ExecutionPHP Opcode Caching
  • 39. Reverse Proxy Servers
  • 40. Reverse Proxy Servers
  • 41. Reverse Proxy Servers
  • 42. Reverse Proxy Servers
  • 43.  Custom PHP/MySQLconfiguration Memcached/PHP APC Joomla! friendly reverse proxysetupOur Own Solution: The SUPERCACHER
  • 44. More tests: Joomla + VirtueMartNo OptimizationsApplication LevelOptimizationsServer LevelOptimizationsPage Load Time 5.22s 3.49s 1.09sTotal Page Size 1.89MB 0.67MB 0.67MBNumber ofRequests76 28 28Page SpeedGradeF (41%) B (85%) A (92%)YSlow Grade C (70%) B (84%) A (94%)
  • 45. Some Key Takes from part 1Speed optimization is a process – do itregularly and you will be rewarded.Always test! Don’t test on a live site, usestaging copy instead! Backup!Choose a well optimized host
  • 46. TAKE A BREAKback in 5!
  • 47. PART 2Let’s get our handsdirty
  • 48. Cloud, VPS or Dedicated?Cloud – can be both awfully slow and cheap or superfast and really expensive, highly scalableVPS – Usually fast and inexpensive, but you’redependent on others on the same box, limitedscalabilityDedicated – usually expensive and fast, not easilyscalableCHOOSING THE METAL
  • 49. Hardware matters! SSD drives for MySQL & Cache SSD Capable File System, if dedicated RAID for files RAM for Caching CPUs that support virtualization BACKUP! BACKUP! BACKUP!
  • 50. We need to install some software on it:1. Web Server2. MySQL3. PHP with Cache4. Memcached5. Static and Reverse Proxy serverNOW THAT YOU HAVE YOURBOX
  • 51. Web server choiceWEB SERVER CHOICE
  • 52. ★ Apache Pros Easy to setup and support, hundreds of modules,free Supports Joomla! out of the box Can be found on 99% of the webhosts preinstalledApache Cons Apache does not scale well and is resource heavy Apache has limited number of concurrent users Apache is generally much slower than NginX in everyaspectApache is the obvious choice.. Or is it?
  • 53. Timeout 30KeepAliveTimeout 10MaxKeepAliveRequests 30StartServers 20MinSpareServers 10MaxSpareServers 20✔ Remove all unused apache modules, this reducesthe request processing time.Apache recommended settings
  • 54. ★ NginX Pros Shorter response times compared to apache Very high number of concurrent users Faster than Apache in serving static content Supports FastCGINginX Cons Not supported by major control panels (cPanel, Plesk) Does not support mod_rewrite out of the box –additional configuration for Joomla!NginX for performance PHP
  • 55. Joomla SEF URLs on NginXAdd this code to nginx.conf file:MORE INFO AT: http://is.gd/qCeuqU# Support Clean (aka Search Engine Friendly)URLs</tt>location / {try_files $uri $uri//index.php?q=$request_uri;}
  • 56. BIND=/tmp/nginx.fcgi.sockUSER=apachePHP_FCGI_CHILDREN=20PHP_FCGI_MAX_REQUESTS=5000PHP_CGI=/usr/bin/php-cgiPHP_CGI_NAME=`basename $PHP_CGI`PHP_CGI_ARGS="- USER=$USER PATH=/usr/binPHP_FCGI_CHILDREN=$PHP_FCGI_CHILDRENPHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"su - $USER -s /bin/bash -c "/usr/bin/env --$PHP_CGI_ARGS &"Setup NginX with FastCGI & PHP
  • 57. 1. Most buffers in MySQL are per connection. Theystore pointers, NOT data.2. Optimize your InnoDB- separate the data files- increase innodb_thread_concurrency (not morethen the amount of cores you have)3. Optimize your query cache.MYSQL SETUP TIPS
  • 58. Expected MySQL Qcache resultsQcache_hits | 61168 |Qcache_inserts | 10068 |Qcache_lowmem_prunes | 0 |Qcache_not_cached | 3 |Qcache_queries_in_cache | 922 |
  • 59. LET’S MAKE PHP FLY
  • 60. FastCGI SetupEnable FastCGI Apache Module FastCGI Wrapper ScriptLoadModule fcgid_modulemodules/mod_fcgid.so# Activate the PHP handling<IfModule mod_fcgid.c><Files ~ (.php)>SetHandler fcgid-scriptFCGIWrapper/var/www/users/wrapper/php-fcgi .phpOptions +ExecCGI</Files>FcgidMaxRequestLen 20000000</IfModule>Wrapper script/var/www/users/wrapper/php-fcgi#!/bin/shexport PHPRC=/etc/exportPHP_FCGI_MAX_REQUESTS=5000export PHP_FCGI_CHILDREN=20exec /usr/bin/php-cgi
  • 61. 1. Install APC:pecl install apc2. Load APC extension in PHP:/usr/local/lib/php.ini - extension=apc.soRecommendation: Keep the default settings!Enable APC
  • 62. Enable Memcached1. Install Memcached (service)yum install memcached2. Install PHP Memcached modulepecl install memcache3. Recommendation: configure Memcached to use Unixdomain socket instead of TCP – improves speed!/usr/bin/memcached -d -m 64 -c 2049 -P/var/run/memcached/memcached-11211.pid -s/tmp/memcache.sock
  • 63. Enable APC/Memcached in Joomla
  • 64. Joomla Patch for Unix Socket ConnectionsEdit the following file:libraries/joomla/cache/storage/memcache.phpChange the code on lines 86-88 fromself::$_db->addServer($server[host], $server[port], $this->_persistent);$memcachetest = @self::$_db->connect($server[host],$server[port]);To:self::$_db->addServer(unix:///tmp/memcache.sock, 0);$memcachetest = @self::$_db->connect(unix:///tmp/memcache.sock, 0);
  • 65.  Move PHP binaries to RAM Move TMP to RAM Move MySQL to an SSD drive or SSD RAID array Enable MySQL query cache Use TMPFS for MySQL’s tmpdir Install Google PageSpeed for apache Enable Gzip compression (mod_deflate on apache2)More Apache/MySQL/PHP Tweaks
  • 66. EVEN BETTERPERFORMANCE?
  • 67.  Also known as Reverse HTTP Proxy Install it in front of any server that speaks HTTP Blazing fast – usually speeds up 300-1000x Performance is usually bound by the speed ofLAN Free, Open Source softwareVarnish - The ultimate web app accelerator
  • 68.  Can be harder to setup and configure than NginX You still need Apache (or NginX, varnish does notknow PHP) Dramatic performance increase – only whencaching dynamic content Caching dynamic content might lead tounexpected troubles!!! Cache should be properlyinvalidated!!!Varnish Cons
  • 69. Varnish VCL? Exclude non-cacheable pages:• registration form• administrator• installation folder Set objects expiration time
  • 70. Sample Varnish Joomla VCLjoomla.vcl:# Bypass Varnish if the request is to the registration formif (req.url ~ "task=registration.register" || req.url ~ "view=registration") {return(pipe);}# Never cache administrator/installationif (req.url ~ "/administrator" || req.url ~ "/installation") {return (pass);}return (lookup);----sub vcl_recv {set req.backend = default;include "joomla.vcl";if (req.url ~ ".(png|gif|jpg|swf|css|js)([?].*)?$") {return (lookup);}
  • 71. How we tested? We use Siege - http://www.joedog.org/siege-home/ Siege command: siege -b -t 60S -f urls.txt -c 20 We use 20 number of simultaneous connections We use a predefined list of URLs – all URLs fromthe default Joomla main page + sample data We measure the number of hits taken for 60secondsTEST THE OPTIMIZATIONS
  • 72. Test Environment Setup• Virtual Machine (VPS)• CPU: 4 cores 2GHz• MEM: 4GB• HDD: 8x500GB SATA II 7,200rpm in RAID 10(on the host)
  • 73. Joomla! Optimizations Test ResultsApache +fcgiApache +fcgi +MemcachedApache+ fcgi +APCApache +fcgi +NginXApache +fcgi +VarnishTransactions3,285 hits 4,316 hits 4,629hits185,462hits178,906 hitsAvailability 99.85% 99.83% 99.86 % 100.00% 100.00%Datatransferred9.20 MB 12.09 MB 12.97 MB 519.08 MB 500.29 MBResponsetime0.29 sec 0.18 sec 0.20 sec 0.01 sec 0.01 sec
  • 74. QUESTIONS TIME
  • 75. THANK YOU!Tenko Nikolovtenko@siteground.com@tnikolovMarian Marinovmm@1h.com

×