If you’re familiar with many of the webpage speed tests out there, you know this is one of the important benchmarks, as an indication of the responsiveness of a webserver or other network resource.
A lot of optimization that goes into TTFB is the back-end processing of the requested reasource.
For example, a static webpage that isn’t being pulled from a database is going to have a faster TTFB than one such as WordPress where the content is being pulled out of mySQL.
WordPress Theme Optimizations
If your website is using WordPress then we have to first look at how well your web server is optimized for pulling this content out of the database.
I like to always encourage our customers to carefully select their WordPress theme and plugins as these can be two big factors into decreasing your TTFB.
Unfortunately a lot of themes and plugins are coded out of convenience without keeping server performance in-mind. WordPress developers nowadays are wanting to sell to the masses vs. creating a theme that’s optimized for high server performance.
I would estimate that the average WordPress theme customer, on say ThemeForest, doesn’t average more than a couple hundred visitors per month.
A lot of WordPress functions can also be completed without the use of a plugin. Even though they can be extremely convenient, it’s best to use as few plugins as possible for optimal performance.
WordPress Server Optimization
Once you’ve optimized your WordPress theme and plugins you need to take a look at the back-end configuration on your server.
The first thing I like to check is the PHP handler. Since WordPress is obviously a PHP/mySQL application on the back-end, these are the first two points of optimization.
Optimizing MySQL For WordPress
Our hosting packages all default with MariaDB.
MariaDB is a community-developed fork of the MySQL relational database management system intended to remain free under the GNU GPL. Some of the original mySQL developers started MariaDB after expressing concern once Oracle acquired mySQL.
Therefore it works the exact same as mySQL (your scripts will still function the same) but with much better performance and redundancy.
If you’re using one of our older virtual private servers, you may want to go to MariaDB upgrade in Web Host Manager and upgrade. However if you’re on one of our newer packages, it’s already installed by default.
Optimize Your my.cnf For WordPress
While installing MariaDB will help with performance, you still need to optimize your my.cnf file, as not all servers are alike.
Unfortunately for those on our hosting, you’re not able to optimize this file as we’ve already done it server-wide.
While we have optimized it for performance, we always have to remember these are Shared servers meaning we have to pick and optimization that works for the masses vs. individual websites.
Simply put, you’re going to have better WordPress performance that you can customize. With all of that said, the main point of optimization inside the my.cnf file is the innodb_buffer_pool_size.
[From mySQL documentation] InnoDB maintains a storage area called the buffer pool for caching data and indexes in memory. Knowing how the InnoDB buffer pool works, and taking advantage of it to keep frequently accessed data in memory, is an important aspect of MySQL tuning. For information about how the InnoDB buffer pool works, see InnoDB Buffer Pool LRU Algorithm.
The more RAM you have in your server you can allocate to the innodb_buffer_pool, the better the performance. As a general rule of thumb, many database administrators have recommended 80% of RAM in the server.
Percona has a fantastic article on their blog explaining this in detail as well as providing this handy chart:
Total Server RAM | Buffer pool with 80% rule | Remaining RAM |
1G | 800MB | 200MB |
16G | 13G | 3G |
32G | 26G | 6G |
64G | 51G | 13G |
128G | 102G | 26G |
256G | 205G | 51G |
512G | 409G | 103G |
1024G | 819G | 205G |
Personally, I’m always a bit more on the conservative side of things, and don’t go quite to 50%, but this is all personal preference. Especially if you’re running Web Host Manager/cPanel on your server you must also take that into consideration and allow enough RAM for it to operate smoothly.