Should I Turn on Both PageSpeed and LSCache at the Same Time?

In some cases, you may want to know if mod_pagespeed works with LiteSpeed Cache. Let's find out with a testing benchmark experiment.

Before we dive into the differences between LSCache and PageSpeed, let's take a quick look at the background of these two functions and their general characteristics.

  • LSCache is a server-side page cache. Page caches save time and resources, and they do so by storing the full content of dynamically-generated pages so that static copies may be served to the user. A page cache allows the server to bypass the process of dynamic page creation and database queries altogether. Unlike Varnish, LiteSpeed cache is built into LiteSpeed's web server, thus eliminating one layer of reverse proxy. This translates into higher efficiency for static content.
  • PageSpeed is an open-source module which automatically applies web performance best practices to pages and associated assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow. This module can reduce website loading times by automatically optimizing web pages and the resources within them.

Hardware

  1. Client: 4 cores of Intel(R) Xeon(R)E7-4870 @ 2.40GHz CPU + 4G RAM
  2. Server: 4 cores of Intel(R) Xeon(R)E7-4870 @ 2.40GHz CPU + 4G RAM

OS and Settings

  1. Client:
    1. CentOS 7*64
  2. Server
    1. CentOS 7*64
    2. LSWS v5.2
      1. Disable Keep alive
      2. Increase max connection 200000
      3. WooCommerce demo data, page size = 68k
    3. WP-Plugin v1.2.0.1
    4. mod_pagespeed rules
      1. pagespeed FileCachePath /tmp/lshttpd/pagespeed;
        pagespeed RewriteLevel CoreFilters;	
    5. htop v2.0.2

Testing Method

There are four scenarios in our experiment:

  1. Do not use LSCache or mod_pagespeed
  2. Only use mod_pagespeed
  3. Only use LSCache
  4. Use both LSCache and mod_pagespeed

Regardless of whether we are testing with LSCache or mod_pagespeed, we follow the same procedure:

  • Test the web servers using ApacheBench (an HTTP server benchmarking tool). In each test, the client sends 10,000 requests of 68kB each to the server's webpage.
  • Before each test the web server in question is restarted to clear out any potential caching or other issues that may interfere with results.
  • Each test is run with the same concurrent numbers of requests to gauge performance for different cases.
  • The commands that are used in this test follow this format:
    ab -n 10000 -H "Accept-Encoding: gzip,deflate" -c 10 http://$Server_IP/wordpress/

Comparison Table

Case LSCache Mod_PageSpeed Requests/s Memory usage(MB) CPU Load 1min
1 X X 16 210 7.33
2 X O 21 300 8.42
3 O X 8152 1 2.50
4 O O 4469 100 3.52
  • CPU Load default average value is 0.3
  • Memory usage numbers do not include the system's base memory usage, which has been subtracted from the total

Comparison Chart

Requests per second

LSCache clearly dominates in the raw number of requests per second it can serve. The difference between cases with LSCache and cases without LSCache is too large to chart them side-by-side, so we've created two separate charts.

  • Comparing Case 1 and Case 2 by requests per second, we can see there is 20% increase with mod_pagespeed
  • You will notice from this graph that with LSCache and PageSpeed both enabled, the numbers are lower than that of just LSCache but greater than just PageSpeed. The reason for this is that on a normal load of the webpage, LSWS will serve the cached file and all of the static files that are requested without having to do any CPU-intensive tasks. When PageSpeed comes into play LSWS will serve the cached page, removing any need for PHP. This will be quicker, but then it has to optimize all of the other static content via mod_pagespeed before it gets served to the user. In return, one receives optimized static files but at a cost of server resources and less requests per second.

CPU Load

  • For this test, we continually send requests for the duration of exactly 1 minute. Comparing all cases, we can see CPU Load is highest with only mod_pagespeed is enabled. Cases 3 & 4, in which LSCache is enabled, are not overloading.

Memory usage

  • This is important to measure, especially on a VPS where your memory usage has a hard cap and raising it costs you additional money. Comparing all cases by memory usage, we can see there is a 30% increase with mod_pagespeed running than with nothing enabled.


Remember, the results shown are good only for measuring relative (and not absolute) performance, as the tests were conducted locally on the server.

After going over the benchmark testing of both LSCache and mod_pagespeed enabled cases, you may have a better idea of which combination is more suited to your needs.

  1. Using LSCache and mod_pagespeed together is a workable scenario, but it will slow down your page loading time and increase CPU and Memory usage. If your LSWS includes LiteSpeed Cache already, then you don't need to enable the PageSpeed module to shorten the loading time.
  2. If your LSWS does not include LSCache, then PageSpeed does speed up your site by around 20%. It will require significant resources and should be avoided in shared hosting environment. For more information, please see Using a Control Panel in a Shared Hosting Environment.
  3. Seeing these results, you may want to add LSCache to your existing LSWS license.

We welcome your feedback on our forum.

  • Admin
  • Last modified: 2017/09/13 19:43
  • by Lisa Clarke