Performance Enhancements with Kinsta

I host over 1000 WordPress sites with Kinsta and am a huge fan of their hosting services. Performance related issues with Kinsta are almost always plugin and theme related. Kinsta support can enable New Relic’s tracking which is a great way to track down bottleneck coding issues.

Dealing with coding related performance issues can be time consuming and involve coding experts. That said if you’re dealing with performance related issues there are a few quick wins you can do yourself. Here are my top #3 performance enhancements with Kinsta.

1. Expand cache coverage.

Kinsta’s cache covers static files and most pages. The default cache configuration works well for the majority of WordPress sites. If you’re having performance issues then it’s a good idea to review the cache coverage within Kinsta’s analytics. Too many uncached requests can fill up the PHP workers which leads to sporadic 502/504 errors. From https://my.kinsta.com select Analytics then Cache.

Kinsta’s top cache bypasses

Kinsta’s cache does not cover query strings by default. Start by reviewing the top cache bypasses for any common query strings that would be safe to include in the cache. A few common query strings I see are sccss=, cn-reloaded= and relatedposts=. You can have Kinsta support add NGINX rules to cover specific query strings link so:

if ( $query_string ~ "^sccss=" ) {
   set $skip_cache 0;
}
if ( $query_string ~ "^cn-reloaded=" ) {
   set $skip_cache 0;
}
if ( $query_string ~ "^relatedposts=" ) {
   set $skip_cache 0;
}

This can make a huge improvement especially for high traffic sites. Here is a before and after comparison for a customer I recently helped out.

New site launch before and after increasing cache coverage.

2. Disable default WordPress cron and lower system cron interval.

The default WordPress cron process is triggered by traffic. For high traffic sites this can be problematic by excessively running WordPress cron. I recommend disabling that by adding define( 'DISABLE_WP_CRON', true ); to wp-config.php. Refer to Kinsta’s article for a more technical breakdown.

The WordPress cron will still be triggered by Kinsta’s system level cron job however that is set to run every 15 minutes. I recommend lowering that to every 5 minutes which is the lowest allowed by Kinsta. To do that connect to the site over SSH then edit the crontab.

crontab -e

You should see a line that looks something like this.

Change the beginning part from 13,28,43,58 * * * * to */5 * * * * then save. This process will now run every 5 minutes instead of the default 15 minutes.

3. Install Perfmatters and lower heartbeat interval.

Websites with many back end users can generate quite a bit of uncachable background traffic. This noise can be lowered by adjusting the default heartbeat interval. While there are plenty of plugins which allow you do adjust just the heartbeat interval I highly recommend using Perfmatters.

Perfmatters is well-built and has many common performance enhancements. Each option is clearly explained with exceptional documentation. Regarding heartbeat specifically, I like to go with the following options:

  • Set “Disable Heartbeat” to “Only Allow When Editing Posts/Pages”
  • Set “Heartbeat Frequency” to “60 Seconds”

Refer to their official documentation: https://perfmatters.io/docs/change-heartbeat-frequency-wordpress/.