Lowering TTFB on a Joomla website
I spend the last 7 days looking for a way to lower the Time To First Byte (TTFB) on a website. It was taking from 79 to 90 seconds everytime you loaded the site for the first time.
My site is configured with:
- PHP 7
- Apache 2 + gzip + mod_ssl + mod_pagespeed + memcached. Pagespeed using memcached too.
- OpenSSL + a Comodo certificate
- 10GB Ram + enough hdd space
After the first load, the site was loading extremely fast in less than 3 seconds.
It wasn't the server. It was the Joomla configuration. I also had the JCH Optimize plugin to compress everything but I wasn't paying attention that on the first load, the site was packing all the images before displaying the site. I had to enable the images lazy load option to load the whole page and then the images.
After this change, times dropped to an average of 10 seconds on the first load then about 3 seconds on internal pages as you were navigating the site. This worked for some weeks but the server kept failing.
I had to disable JUX Social Counter module that was used to show live numbers of our social media pages. This was the real cause of the long TTFB.
Third run (final):
I changed hosting provider to Knownhost, changed Apache for Litespeed with cache and changed the database to MariaDB. Loading times dropped from 30s. to less than 5s. with the same load.
TTFB on a Joomla site with an average of 6k visitors a day with more than 100k articles on database can bring some problems you won't experiment on development or with a small server. Plugins start to play an important role on loading time, if you have outdated plugins it's better to update them to latest version.
Memory, configuration, modules, compression it all plays a role here. I found that switching to a SSD hosting with cpanel (Knownhost I really recommend this) reduced the loading time and general response to less than a third.
I decided to test Litespeed webserver + litespeed cache (there's a tweak you have to do to use it with Joomla) because I was tired of configuring apache back and forth. It really worked fast and stable.
When you have a lot of content, databases need to be optimized too. Mysql is the default but it's joins aren't as good as MariaDB. It's an easy upgrade with a WHM+Cpanel hosting. This was the final trick.
- Hits: 1403