Magento 2 Performance – Litespeed + LiteMage Cache vs Varnish, Turpentine, Redis

cachelitespeedmagento2performancevarnish

I am in the process of setting up a new Magento 2.3 store with Apache, Varnish (probably Turpentine) and Redis. All requests will be via HTTPS (SSL). I recently became aware of the Litespeed Web Server, LiteMage Cache and the company's Magento extension. I wonder if I should switch from Apache to Litespeed?

The advertisements show this combination massively outperforming Apache + Varnish as well as Nginx + Varnish + Turpentine. Here's a quote from an advertisement:

  • It is up to six times faster than Apache
  • It is three times faster than Apache in SSL
  • With its LiteMage cache, LiteSpeed makes Magneto pages to run up to 75 times faster
  • It increases PHP performance by 50%

I'm skeptical. Should I believe any of those claims? I see a lot of ads and promotions from those making money from this combo (hosting companies) but I'm not finding much independent benchmarking. Litespeed's benchmark page is here. They claim:

LiteSpeed Web Server with LiteMage Cache was up to 3 times faster than nginx with Varnish, and 4 times faster than Apache with Varnish.

If LiteSpeed + LiteMage Cache is really that much faster, why aren't more people discussing it here? I find very few questions related to it.

I would rather not get locked into a proprietary solution if I can do as well or nearly as well with the widely used free solutions. Looking for advice. The purpose of this post is to gets the facts from reliable sources who have experience rather than from advertisements promoting a for-profit product. I would spend the money for LiteMage, but only if it is really worth it based on real-world experience from folks here. Thanks.

Best Answer

Should I believe any of those claims?

You shouldn't believe any claims unless you can independently verify them.

That said, it's easy to decipher why LiteSpeed could be somewhat faster than other setups.

Let's take the most performant open source stack which consists of NGINX + Varnish.

NGINX terminates TLS and proxies that over to Varnish, which is the caching layer.

In its turn, Varnish proxies request to the backend (if it is not satisfiable from the cache at the moment), over to NGINX again.

So it is an NGINX sandwich of sorts. The potential performance offenders here is proxy buffering in both NGINX and Varnish.

What proxy buffering means, in short, is that before giving output to the client, NGINX #1 (TLS) will wait to collect a small amount of response data from Varnish (which is the backend to NGINX #1).

This is behavior, which is by default (proxy buffering is enabled). It is primarily useful for ensuring that the slow client will not "burn down" backend connections (which are typically RAM-hungry):

Say you have one really slow client, and NGINX proxy buffering is not enabled. It means that a connection is fully "consumed" by the client, while it's slowly receiving data. NGINX must keep the connection to its backend (normally, it's PHP-FPM in other setups), while synchronously delivering data to the client.

With proxy buffering enabled, NGINX can close the connection to the backend (which is good, especially if it required a good amount of RAM, in case of PHP-FPM as backend), as soon as it got the whole response from it, and then NGINX can release the data to the client, while the backend is free to do other stuff.

However, in the NGINX sandwich kind of stack (Magento 2 case), it is arguable whether you need proxy buffering all the way and you may want to tune it (and it would surely produce better results).

Why is because you would then reduce the time it takes for different components of the stack to "talk" to each other. Again, those are:

NGINX #1 (TLS) -> Varnish -> NGINX -> PHP-FPM.

Keeping buffering in NGINX #1 is not very essential because its backend is a lightweight process (Varnish). The same applies to Varnish -> NGINX link. But buffering there is absolutely required because this is how the caching works in Varnish - it has to get the entire response in order to cache it.

So either way, you can decipher from all of this, that having LiteSpeed combine TLS termination feature of the above stack, and not just that, is already a win because it won't cause extra buffering between different software components.

If LiteSpeed + LiteMage Cache is really that much faster

It really isn't that much faster! Those numbers where NGINX+Varnish performs at 3K requests per second are very good, not to even bother considering other solutions.

why aren't more people discussing it here?

Because it's commercial, and you'd rarely if ever, hit the ceiling with the Varnish solution. You need to have an Uber-size traffic Magento 2 instance (literally) to warrant the need for Litespeed, although I would just fine-tune things with proxy buffering as a first step.

Again, these numbers from Litespeed look like they are, and maybe they are times better. But this is more of a marketing thing, e.g.: would you really bother so much if you had a trillion dollars which you can never spend in your entire lifetime but then someone offered you another 2 trillions for doing some extra work? I'd say "meh, I am fine with my trillion, thank you" :)

Related Topic