Boost Performance of your Xenforo Community!

Boost Performance of your Xenforo Community!

In our last article, we saw how we can boost the performance of vanilla forums. Compared to Xenforo vanilla is lightweight, however, Xenforo offers more features, with more features in mind Xenforo is choice of community software for many community managers.

For Xenforo version 1.x and 2.x LiteSpeed have a plugin which you can use out of the box to boost the performance.  Fortunately, Xenforo also has a special cookie for logged in users, which we can use to identify between logged in and logged out users.

Step 1: Install CyberPanel and create your website!

Before we get started, you need to install CyberPanel and create your website.

Step 2: Download and install Xenforo Forums 2.x!

Xenforo version 2.0.4 was already released when I was writing this article. Once you have a license you can log in to their client area to download Xenforo. We will be using the File manager to upload Xenforo.

Once a website is launched scroll down to find the File manager.

This will launch File manager, using which you can upload your Xenforo forums zip file, make sure you have increased your upload limit to at least 10MB, because Xenforo forum file size is ~8MB.

Once uploaded and unzipped, you can visit your domain to start the installation. Before that let’s create a database that Xenforo is going to use.

Create Database!

From left sidebar click ‘Create Database’, select website from the drop down so that you can create a database.

Start Installation!

To install Xenforo open your website URL where you have uploaded and unzipped Xenforo, in this case, it is ‘xenforo.cyberpanel.net’.

First Screen

Second Screen

Enter the database details that you created in the last step and click ‘Save config’. Next two are just confirmation screens which let you start the installation.

Create Administrator!

Create administrator account, replacing following details as required.

Setup options

This is the last step before you are ready to use your Xenforo forum. Fill above details accordingly and click ‘Setup options’. Finally, frontend of your Xenforo community should look like:

It is time we boost the performance of our Xenforo community.

Step 3: Boost your Xenforo Community with LSCache!

As I’ve already discussed above that Xenforo is heavier on resources than vanilla forum so it would be a good thing to use the cache as much as we can. I must say that personally, I started liking the features Xenforo offers, however features comes at a cost and more server resources.

First, download and install Xenforo LiteSpeed cache plugin. once you locally extract this compressed file you will see following file structure:

lscachexf2-2.0 -> upload -> src.

You need to upload this src folder to root of your Xenforo installation and overwrite any old files (if any) so that you get the latest version of the plugin. After you upload the files you must have a folder named LiteSpeedCache in: Xenforo Installation Path – > src -> addons

After that go to http://example.com/admin.php?add-ons/

And install the plugin through Xenforo.

Let see the state of cookies when a user is not logged into Xenforo community:

And once logged in:

I can see that xf_user is the new cookie once logged in, which we can use to distinguish between guest and logged out users. So our rewrite rules will look like:

Use the rewrite rule guide to setup rewrite rules on CyberPanel. Once these rules are set LSCache will start working for logged out users.

Disable reqCookieCache and respCookieCache

For some reason when these two parameters are enabled, upon Xenforo login you also get a cache hit, which should not be the case. For now there is a temporary fix to disable these two parameters:

  • reqCookieCache 0
  • respCookieCache 0

They can be disabled in /usr/local/lsws/conf/httpd_config.conf

Benchmarks

In my last article, I used KVM instance for benchmarks, this time I am going to use OpenVZ, and tests are performed in exactly the same environment for both OpenLiteSpeed and Nginx (Apache backend).

  • OpenVZ
  • 2 vCPU.
  • 2 GB Ram.
  • SATA Disk.

OpenLiteSpeed Performance

Command used to perform benchmarks:

  • 1st Run: 0.455 Seconds.
  • 2nd Run: 0.418 Seconds.
  • Third Run: 0.414 Seconds.
  • 4th Run: 0.410 Seconds.

Average total time takes for requests: 0.424 Seconds

NGINX (Apache backend) Performance

Command used to perform benchmarks:

  • 1st Run: 407.382 Seconds.
  • 2nd Run: 408.428 Seconds.
  • Third Run: 427.274 Seconds.
  • 4th Run: 420.698 Seconds.

Average total time takes for requests: 415.9455 Seconds

For complete details on benchmark see forum post here.

Conclusion

You can already see the performance gain you are going to have, which leads to fewer server resources and more visitors. However, Xenforo LiteSpeedCache plugin currently does not use tag-based cache invalidation, that’s why I set the cache max-age to 120 seconds.

Hopefully in upcoming versions of the plugin, it is going to use tag based cache invalidation, which will help cache the pages for longer period of time and hence more productivity.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: