Host Whimsy Blog

Explore expert insights and tips on enhancing your digital footprint, from SEO strategies to securing the ideal domain for your brand.

LiteSpeed, Apache and Nginx: The differences

LiteSpeed, Apache and Nginx: The differences

Which one should you choose for your website and why?

If you’re looking for a web server to launch your website, there’s a high chance that you’ll be faced with a decision to choose between these three web servers: Apache, LiteSpeed or Nginx. And when you do, you’ll want to make a well-informed decision.

Everyone thinking of launching a website today is looking to one up their competitors. In the competitive world today, where people can’t tolerate a second’s delay between their clicks and their loaded pages, a split second may be the difference between a successful business and a failed attempt. That two second loading delay may cost a company valuable customers. Therefore the decision of which web server to rely on for your precious website is a monumental one. 

Out of the three named web servers, Apache is the oldest, which is why it’s still the most widely used. It’s free (open source), however, its popularity has taken a hit recently with the arrival of other newer web servers.

The problems with Apache begin with the core construction of how it manages requests. It’s a process based approach in which resources are allocated from the beginning when a single process begins, and stay occupied until that entire process ends. The server creates a new thread/process for each connection, creating considerable overhead for the CPU. Thus CPU and memory usage increases exponentially with increased traffic. This is why, for websites running on Apache, when traffic increases it is common for the hosting provider to send out a message which prompts the website owner to upgrade to a VPS. 

Apache is not very scalable when it comes to high traffic websites, and increasingly consumes more resources. There is the option of using a reverse proxy on top of Apache such as Nginx or Varnish to serve static elements while Apache handles requests in PHP. This setup consumes fewer resources and allows a server to support higher traffic. The issue with that would be availability. Very few hosts offer such as a set-up. It increases complexity, and decreases profitability for the host.

Unlike Apache, LiteSpeed and Nginx both use event-driven approaches. LiteSpeed is the newest web server amongst the three. It processes PHP scripts in half the time compared to Apache and serves static elements up to 4 times as fast. Due to its event-driven construction, it consumes fewer resources and thus, can support higher traffic. It serves all connections with only one or a few processes. This one process handles all events that appear, and the server is concerned, not with creating new processes, but with reacting to each event that occurs. 

For static content, LiteSpeed’s one process simply handles each request as it is made, instead of creating a new process each time, making it much faster and consuming less CPU and memory compared to Apache. For web applications and database processes, LiteSpeed forwards it to external processes that create appropriate responses. While this continues, the server does not wait around, but instead keeps processing other requests, with static requests being immediately processed and dynamic ones being forwarded to external processes. When a dynamic requests response is ready, the server gets a call-back which is treated as a new event to react to, and delivers this response to the appropriate client. Additionally each new external process is kept track of so that it can be reused if a similar request is made, instead of creating another process, further increasing CPU and memory efficiency. 

A large number of companies have tried, what may be called the “brute-force” attempt at solving the CPU and memory inefficiency of Apache by continuously increasing their hardware. LiteSpeed renders this unnecessary. By acquiring greater CPU and memory efficiency, you save costs of extra hardware as well as support. LiteSpeed can support all of Apache’s functionality and outclasses it on almost all levels. Furthermore, it also has integrated DDoS protection. With the stability, performance and scalability that LiteSpeed offers  the small subscription fee is entirely reasonable.

Finally, we have Nginx. Nginx does not necessarily need to be used as a reverse proxy on top of Apache, and can also be used as a standalone web server. Like LiteSpeed, Nginx’s similarly event-driven construction allows it to serve pages a lot faster than Apache. It is hugely scalable, and possesses the ability to support thousands of concurrent connections simultaneously, since that is why it was invented. It boasts minimal resource consumption and that too in a very predictable way. 

Alas, there is a catch. Nginx does not have an integrated PHP mode, and thus a separate server PHP-FPM, namely PHP5 is required for communications. Moreover, Nginx cannot be used on a shared hosting plan, and is commonly used on a Virtually Private Server (VPS), which increases expenses. 

At the end of the day, without using a reverse proxy on top of Apache, it simply cannot hold a candle to LiteSpeed or Nginx’s event driven model. When using LiteSpeed, an efficient pairing would be to use CloudLinux operating system instead of CentOS. This ensures optimal security, performance and scalability. When every second matters, the investment into using a shared hosting plan with LiteSpeed, instead of the standard setup of Apache and CentOS, is an advisable one. Web hosts such as Host Whimsy are offering shared hosting plans with LiteSpeed Web Server in conjunction with CloudLinux OS.

When it comes right to it, the web server that you should use should be the one which best fits your website’s needs. Foresight in these matters, however, is essential and can be the very thing which saves you the trouble of switching web servers in the future and the risk of losing those all-important customers.

Share on Facebook