This document summarizes a presentation on optimizing Joomla performance. It describes two parts to the presentation:
Part 1 covers basic application-level optimizations for Joomla like keeping Joomla updated, choosing extensions wisely, simplifying templates, and using plugins and .htaccess rules to enable caching and compression.
Part 2 discusses server-level optimizations like using a CDN, opcode caching with APC and Memcached, and reverse proxy servers like Nginx and Varnish. It provides configuration examples and presents results of benchmark tests showing improvements from optimizations.
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 everything
fast
8. Marian’s Bio
Sysadmin since 1996
CEO and Co-Founder of 1H Ltd. and
mastermind behind 1H Hive
Computer science teacher at Sofia
University since 2007
Coordinator of OpenFest (Bulgaria's
biggest FOSS conference) since 2005
Regular speaker at FOSS conferences
in the Balkan region
9. Devs/Sysadmins who love to ssh and do everything on
their own – cloud/vps/dedicated server owners
Large/high traffic Joomla websites owners
Multiple Joomla websites owners
Performance Geeks
WHO CARES ABOUT
PERFORMANCE?
11. Site speed affects your Google Rankings!
Keep readers/customers happy & paying
Be able to handle more visitors
Go green and save $$$ from servers
WHY CARE ABOUT
PERFORMANCE
14. Keep your Joomla! updated
Choose extensions wisely
Deactivate unused extensions, upgrade used
Simplify your templates as much as possible
GENERAL GUIDELINES
15. Simple Front Page Is Better
Fancy stuff – only if you really need it
Remove unnecessary large images
Use fewer internal/external links – add
sitemap
Avoid loading content from remote servers
17. Enable Compression
Natively supported by Joomla! – no extensions needed
Requires mod_gzip/deflate to be enabled on the server
Site
Global
Configuration
Server
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 be
reloaded
- Expires Headers – Set different expiration dates for various file
types
- AddOutputFilterByType DEFLATE – minifies the compiled HTML
source code
21. Some .htaccess Magic
The code:
FileETag MTime Size
AddOutputFilterByType DEFLATE text/html text/css application/javascript
ExpiresActive On
ExpiresDefault "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 Core
Cache
Cache Cleaner – easily clean the cache from the
Joomla! admin panel
27. Google mod_pagespeed
An open-source Apache module - compress,
combine and cache
Needs to be installed/configured by a System
Administrator
Available on SiteGround servers
29. Some tests – Default Joomla!
No Optimizations Cache/
Compression
.htacce
ss rules
JCH
Page Load
Time
1.61s 1.49s 1.32s 1.02s
Total Page
Size
563KB 162KB 162KB 151KB
Number of
Requests
35 35 35 19
Page
Speed
Grade
F (41%) B (65%)
B
(87%)
A
(91%)
YSlow
Grade
C (70%) B (66%)
B
(86%)
A
(92%)
32. CDN Features
CDN will make your website faster
CDN will help avoid unneeded I/O on your hard
drives
CDN will appeal to both Google and your visitors
44. More tests: Joomla + VirtueMart
No Optimizations
Application Level
Optimizations
Server Level
Optimizations
Page Load Time 5.22s 3.49s 1.09s
Total Page Size 1.89MB 0.67MB 0.67MB
Number of
Requests
76 28 28
Page Speed
Grade
F (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 it
regularly and you will be rewarded.
Always test! Don’t test on a live site, use
staging copy instead! Backup!
Choose a well optimized host
48. Cloud, VPS or Dedicated?
Cloud – can be both awfully slow and cheap or super
fast and really expensive, highly scalable
VPS – Usually fast and inexpensive, but you’re
dependent on others on the same box, limited
scalability
Dedicated – usually expensive and fast, not easily
scalable
CHOOSING 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 Server
2. MySQL
3. PHP with Cache
4. Memcached
5. Static and Reverse Proxy server
NOW THAT YOU HAVE YOUR
BOX
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 every
aspect
Apache is the obvious choice.. Or is it?
53. Timeout 30
KeepAliveTimeout 10
MaxKeepAliveRequests 30
StartServers 20
MinSpareServers 10
MaxSpareServers 20
✔ Remove all unused apache modules, this reduces
the 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 NginX
Add 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;
}
57. 1. Most buffers in MySQL are per connection. They
store pointers, NOT data.
2. Optimize your InnoDB
- separate the data files
- increase innodb_thread_concurrency (not more
then the amount of cores you have)
3. Optimize your query cache.
MYSQL SETUP TIPS
64. Joomla Patch for Unix Socket Connecti
ons
Edit the following file:
libraries/joomla/cache/storage/memcache.php
Change the code on lines 86-88 from
self::$_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 apache
2)
More Apache/MySQL/PHP Tweaks
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 of
LAN
Free, Open Source software
Varnish - The ultimate web app acceler
ator
68. Can be harder to setup and configure than NginX
You still need Apache (or NginX, varnish does not
know PHP)
Dramatic performance increase – only when
caching dynamic content
Caching dynamic content might lead to
unexpected troubles!!! Cache should be properly
invalidated!!!
Varnish Cons
69. Varnish VCL?
Exclude non-cacheable pages:
• registration form
• administrator
• installation folder
Set objects expiration time
70. Sample Varnish Joomla VCL
joomla.vcl:
# Bypass Varnish if the request is to the registration form
if (req.url ~ "task=registration.register" || req.url ~ "view=registration") {
return(pipe);
}
# Never cache administrator/installation
if (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 from
the default Joomla main page + sample data
We measure the number of hits taken for 60
seconds
TEST 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)