Maab S.
9min Read

LiteSpeed vs NGINX vs Apache

LiteSpeed vs NGINS vs Apache

So, you’re shopping around for the perfect web hosting provider, but you’re also keen to see what web server technology they’re using, and you have good reason to do so. Web servers are arguably the most important factor to consider while choosing a host.

You’ve probably heard compelling arguments for the most popular options: LiteSpeed, NGINX, and Apache. All three platforms are stable, well-maintained, and feature-rich. You can’t really go wrong with either of them. However, if you get down to the technical details, you’ll start noticing some subtle nuances, which may make you choose one over the other. Let’s look at these nuances.


What is a web server?

A web server is software that stores or hosts all the files (graphical elements, source code, etc.) that make up a website. Whenever you enter the URL of a website in your browser, a HTTP/HTTPS request is sent to the web server that’s hosting the website.

It’s a web server’s responsibility to look at the contents of the request, and send an appropriate response. For example, if a user enters https://www.hostafrica.com.gh/web-hosting/, the web server must return a response that renders the web hosting page on the user’s browser.

At any time, there can be several users trying to visit different pages of a website. Once again, it’s the web server’s responsibility to serve each of them with the requested content, simultaneously, and as fast as possible.

If a website is a book, web pages would be the regular pages of said book. As with physical books, websites come in different sizes, some with many web pages, graphics, and other HTML elements.

These books need to be stored somewhere, that’s where web servers come into place.

Think of servers as the bookshelves in a library, and web server technology like LiteSpeed, NGINX, and Apache as the speedy librarian who fetches and serves the books to readers.

That’s basically all that a web server does. Now let’s look at how the top 3 web servers fare against each other, in different departments like speed, configuration, OS compatibility, and more. Hopefully, this’ll help you better decide which web server is an ideal fit for your personalised needs.

Take a look at this recent report on web servers usage.

A W3techs graph showing the most used web servers at present
A W3techs graph showing the most used web servers at present

Introducing our contenders: LiteSpeed, NGINX, Apache

Apache

Apache HTTP Server logo

Let’s start with Apache since it’s the oldest of the three. Apache is a reliable web server and has been around since 1995. It was the most popular for quite some time.

This was helped by the fact that the software is super user-friendly (more so than NGINX), so a rudimentary knowledge of hosting should be enough to set it up.

NGINX

NGINX-Logo-White_blue background

Pronounced as Engine X, NGINX is LiteSpeed’s top competitor when it comes to speed and event driven scalability.

NGINX was originally created to improve the function of Apache. Back then it was a reverse proxy and load balancer. Basically, software that helped web servers balance the load of requests and demands.

Now, it’s transformed into a web server of its own and is the most popular choice around the world.

A BuiltWith graph showing Nginx usage over time, currently experiencing a small drop in market share
A BuiltWith graph showing NGINX usage over time, currently experiencing a small drop in market share

LiteSpeed

LiteSpeed logo

LiteSpeed is the newest of these three challengers, and fast becoming one of the more popular choices. As with NGINX, they took a good look at long-time leader Apache and prioritised speed and customisability.

It’s designed as an Apache drop-in replacement, meaning it’s coded to seamlessly drop in, read, and replace Apache files with a hitch. It’s compatible with many of Apache’s features like .htaccess, mod_rewrite, and mod_security.

A  BuiltWith graph showing Litespeed's growing popularity as a web server
A BuiltWith graph showing LiteSpeed’s growing popularity of their Web Server

In South Africa, Apache still reigns supreme, but as people become aware of LiteSpeed’s capabilities word will spread from abroad to South African shores, as it so often does.

A BuiltWith graph showing the web server distribution in South Africa. Apache leads the pack with 60% share
A BuiltWith graph showing the web server distribution in South Africa. Apache leads the pack with 60% share

TL;DR infographic: LiteSpeed vs NGINX vs Apache

We’ve summarised the features below into this TL;DR comparison table infographic:

LiteSpeed vs NGINX vs Apache comparison table graphic

Architecture

Apache

Apache has a process-based architecture: each HTTP request is handled by a separate process. There is a master process that spawns a new process for every new HTTP request it receives.

The problem with process-based architectures is that there’s a lot of memory overhead: there are as many processes as active connections. In peak hours, your memory utilization may rise exponentially.

If this doesn’t make sense, read our analogy:

Think of a server as a restaurant: people come in (traffic), order food (request web pages), and eat (view those pages), then finally pay their bills, and leave.

In our analogy, the waiters are the processes that handle the various requests to the server.

Apache’s processed-based model translates to one waiter per customer. So, the one waiter will take care of everything. From handling the order, to preparing the food, payment, etc.

This means the more customers there are, the more waiters are needed to handle the load. If there’re more customers than waiters, a queue is formed, and you see where this is going.

NGINX

On the other hand, NGINX has an event-driven architecture: a new event is generated for every incoming HTTP request.

The event-driven process model works like this: there’s a master process, and multiple worker/helper processes. The master process oversees the management of the entire server, and performs all the privileged operations (reading configurations, binding ports etc.).

The operational workload of the server is distributed across various worker processes.

Running with our analogy above, one waiter will take multiple orders from different customers and delegate to other waiters as needed. This means people enter the restaurant, place their orders, and get served with minimal wait time. Queuing is processed faster, and the bottleneck becomes non-existent.

This is why event-driven architectures are much more lightweight and efficient. Your memory utilisation doesn’t vary too much during peak and off-peak hours, as the same number of worker threads share the load among themselves.

LiteSpeed

LiteSpeed also has an event-driven architecture that’s very similar to that of NGINX.


Speed

Apache’s process-based architecture usually means higher RAM usage and longer response times, especially during peak hours and stress runs.

NGINX is relatively faster than Apache, but LiteSpeed is undoubtedly the fastest of the lot. 

The LiteSpeed team deployed WordPress instances on each of the three web servers, and ran a few tests to compute the following benchmarks:

Apache (with their own W3 Total Cache): 826.5 requests per second.

NGINX (with their own FastCGI Cache): 6,025.3 requests per second

LiteSpeed (with LiteSpeed Cache for WordPress): 69,618.5 requests per second

Click on the image below to view their site providing the details of their test environment:

A Litespeedtech graph showing Litespeed's swiftness in handling requests via HTTP/2
A LiteSpeedtech graph showing LiteSpeed’s swiftness in handling requests via HTTP/2

Similar trends have been observed in other bench-marking efforts. Check out this LiteSpeed graph displaying amount of transactions per second:

A Litespeedtech graph showing the amount of transactions/second with and without Keep-Alive
A LiteSpeedtech graph showing the amount of transactions/second with and without Keep-Alive

HOSTAFRICA tests

We ran our own tests on a real website, and this is how Apache compared to LiteSpeed. We used the same site across both platforms, with and without caching enabled.

LiteSpeed vs Apache performance comparison by HOSTAFRICA
LiteSpeed vs Apache performance comparison by HOSTAFRICA

With Google favoring First Contentful Paint and First Meaningful Paint as part of the Core Web Vital metrics, you can see how much of an improvement LSCache has on these metrics and page speed when properly configured.

Hosting packages with additional resources with us will also see further improvements.


Caching

A cache is software used for temporary storage of frequently accessed data. Web server caches store frequently accessed webpages and resources. Here’s how a typical web server operates with caching enabled:

  1. The browser sends an HTTP request to the server.
  2. If the requested data is present in the cache, the cache intercepts the request and responds to it, without burdening the web server.
  3. If the requested data is not present in the cache, the web server responds to the request. The cache may store the data if it matches any configured caching filters.

This decreases the server’s workload, increases the overall performance/bandwidth of the website, and decreases web page load times.

Apache

Apache has various caching modules, like: mod_cache, mod_cache_disk, mod_file_cache and htcacheclean. You can get access to features like: pre-loading files to memory on startup, implementing caching filters, and server-wide key-value based object caching.

NGINX

NGINX caching can be enabled via cPanel. Some of the available features are: ability to add multiple users to caching, force-expiry of cache after configured time, and changing the default default location.

LiteSpeed

LiteSpeed ships with LiteSpeed cache, which has some really handy features like server side caching, ability to cache private and public dynamic content on the same page, and integration with Quic.Cloud CDN.

Quic.Cloud CDN is the only CDN that can cache both static and dynamic WordPress content. LiteSpeed cache plugins are also available for various web applications, like WordPress, OpenCart, XenForo, Laravel, MediaWiki, etc.

LSCache plugin features and capabilities

OS support

Apache supports all Unix (CentOS, Redhat, Fedora etc.) operating systems and MS Windows.

NGINX supports all Unix systems, and has partial support for Windows.

LiteSpeed supports CentOS 7+, Ubuntu 14.04+, Debian 8+, FreeBSD 9+, and Linux kernel 3.0+.


Ease of configuration

The configuration plays an important role, as many people opt for user-friendly systems, be it web servers or almost anything else.

Apache’s .htaccess file makes it super easy to configure your web server. For example, you can implement redirects, password protection, custom error messages, indexing, and much more using this file.

NGINX configurations can be defined via .conf files. You can control things like the number of worker threads, exposed ports, load balancing, and redirects etc.

Virtually all LiteSpeed configurations can be done from an intuitive graphical user interface. E.g. you can create listeners, open firewall ports, implement redirects, and even read Apache’s .htaccess files.


Security

All three web servers support Modsecurity rules, which provide basic protection against some of the most common attack vectors.

Apache has a great record in terms of security, and a vigilant development community that’s quick to fix any security issues that may arise. It also provides various configuration parameters to protect against DDoS and privilege escalation attacks.

NGINX is also fairly secure by design, and has extensive documentation on how to secure NGINX deployments.

Lastly, LiteSpeed also takes security seriously. It ships with reCAPTCHA support, WordPress brute-force attack protection, and numerous other features to protect against DDoS.


Control panel compatibility

Apache can work with cPanel, Kloxo, Ajenti, OpenPanel, and ZPanel etc.

A lot of control panels work with NGINX as well; cPanel, aaPanel, Vesta, and Hestia CP are a few examples.

LiteSpeed can integrate with a host of control panels:

LiteSpeed supported control panels

Plugins

There are numerous third-party modules for NGINX that are maintained by the developer community. Available features range from HTTP digest authentication to dynamic IP locking.

Apache also has a host of third-party modules providing features like SQL connection management, data compression, CGI script execution etc.

LiteSpeed has a few control panel and Cache plugins, along with an API that makes it easy for developers to integrate with third-party applications.

LiteSpeed Cache plugins for web apps

Scripting language support

You can use Apache with various languages, like PHP, Python, and Perl using third-party modules, like mod_php, mod_python, and mod_perl etc.

NGINX supports 7 languages: Go, JavaScript, Perl, PHP, Python, Ruby, and Java servlet containers (as an experimental module).

LiteSpeed supports all scripting languages, including Perl, PHP, Python, Ruby, and Java.


HTTP3 support

Apache currently doesn’t have HTTP/3 support.

NGINX previewed their HTTP/3 support in 2020, and then released a roadmap for the feature in July, 2021.

LiteSpeed has strong and reliable support for HTTP/3.


CMS integrations

Apache can run WordPress, Joomla, Drupal, Magento, and various other content management systems.

NGINX can run WordPress, Magento, Drupal, Joomla, PrestaShop etc.

LiteSpeed is compatible with WordPress, Joomla, Drupal, Magento, OpenCart, PrestaShop, Shopware, MediaWiki.


Conclusion

Like we’ve pointed out, each web server has its pros and cons. After much debate amongst ourselves we’ve settled on LiteSpeed.

We’ve decided to board the LiteSpeed train early, allowing us incredible server speeds, resource distribution and allocation, and security. We’d like to think we’re ahead of the curve, and our reviews have been confirming it.

Check out our LiteSpeed hosting page and see what offerings are available to you and your future websites.

That may not be the case for you, however. For example, you may have a lot of memory resources to spare, and prefer Apache’s process-based architecture for your applications.

The bottom-line is that even though LiteSpeed outperforms its counterparts in most departments, that doesn’t mean it’s necessarily the ideal fit for you as well. Try to understand the strengths and weaknesses of each server, see how they match your personalized needs, and then make an informed decision.

Once more, each web server offers something that makes it worth using. We decided LiteSpeed would suit us best and we’ve had plenty of good reviews to supplement our servers purring like a satisfied cat.


The Author

Maab S.

Maab is an experienced software engineer who specializes in explaining technical topics to a wider audience.

More posts from Maab