LiteSpeed Web Server for Highly-Loaded PHP Applications

By | September 18, 2019

LiteSpeed-Web-Server

 

The LiteSpeed Web Server is a highly scalable PHP web server with high performance and low memory consumption. It is built based on the best practices of the PHP hosting, utilizing the benefits of both Apache and NGINX implementations, and integrating its own optimizations.

The feature-rich structure of the LiteSpeed application server includes the following specifics:

  • an event-driven architecture (like NGINX) consumes fewer resources than Apache process-based model, ensuring better performance with minimum memory and CPU usage
  • full compatibility with commonly used Apache features including mod_rewrite, .htaccess, and mod_security
  • individual optimization for the most popular hosting platforms (e.g. WordPress, Magento, Drupal, Joomla, etc.)
  • ESI cache, CSS and JavaScript optimization, image optimization, browser and object cache support, CDN support, built-in WAF, Geo-DNS, CAPTCHA, IP throttling, cutting-edge anti-DDoS features, etc.

Jelastic PaaS supports LiteSpeed solution out-of-box to provide a secure, efficient, and scalable server for the PHP hosting in the cloud. According to our benchmark tests, the LiteSpeed performance capacity varies from just a few times up to ten times higher than the main competitors such as Apache and NGINX web servers. Below you’ll see the results of testing, as well as how to install, configure and track performance of LiteSpeed WS within Jelastic PaaS.

LiteSpeed Web Server Installation

1. Log into your Jelastic account and click New Environment at the top.

litespeed web server new environment

2. Within the opened topology wizard, switch to the PHP tab and select LiteSpeed Web Server as your application server. Set other configurations up to your needs (e.g. cloudlets limit, Public IPs, region, etc).

litespeed web server environment topology

3. Once the environment is created, you can click on the Open in Browser button next to the application server.

litespeed web server open in browser

4. Within the opened default page, you’ll see your server’s phpinfo data.

litespeed web server phpinfo

The environment is ready for your PHP application to be deployed.

LiteSpeed Web Server Administration

In contrast to Apache or NGNIX, the LiteSpeed Web Server is configurable via a WebAdmin console by default and can be reached using URL and credentials provided in the respective email after installation.

litespeed web server email

litespeed web server admin panel

The WebAdmin Console is a very well documented application that has a user-friendly self-described interface with three main areas: General, Configuration, WebAdmin Console

litespeed web server interface

LiteSpeed Web Server General Management Actions

The section General allows to perform common operations with a regular web server using the following options:

  • Restart allows to restart the web server, detached php processes and virtual hosts
  • Toggle Debug Logging allows to enable/disable debug level logging in an emergency manner. Always set debug level to NONE if you do not need detailed debug logging. Active debug logging will severely degrade service performance and potentially saturate disk space in a very short time. Debug logging includes detailed information for each request and response
  • Server Log Viewerdisplays server logs of different levels using a user-friendly representation
  • Real-Time Statsthis module is a powerful tool to carry out server workload analysis

litespeed web server management

  • Version Managerthis tool allows performing web server version updates.

litespeed web server version manager

In order to keep your environment compatible with Jelastic platform, it is strongly recommended using Redeploy Containers functionality via the dashboard and do not use the LiteSpeed Version Management (use only you are confident in your actions).

litespeed web server redeploy

  • Compile PHP – allows to compile PHP for LiteSpeed Web Server

LiteSpeed Web Server Configuration

Configuration area provides tools to configure:

  • Multiple Server parameters

litespeed web server parameters

  •  Listeners

litespeed web server listeners

  • Virtual Hosts

  • Virtual Host Templates

LiteSpeed Web Server Security Configuration

LiteSpeed Web Server was initially designed to be resistant to a large number of threats and effective workload handling. There can be managed the following security parameters:

  • WordPress Brute Force Attacks Protectionprotects shared hosting WordPress environments from large-scale brute force attacks, which have the potential to bring down entire servers, trying to gain access to a website by repeatedly attempting to guess a valid username and password.
  • Web Application Firewall (WAF) built-in security features to block bad connections. It allows you to enable ModSecurity, allowing sophisticated rules for filtering out attacking requests by checking for known attack signatures. LiteSpeed WS also works well with popular mod_security rules set such as Owasp, Atomicorp, Comodo and CloudLinux Imunify360. A big difference compared to Apache or other web servers is that LiteSpeed WAF ​​can manage specifically rules for dynamic requests. This means that computing power can be significantly optimized.
  • Per Client Throttling – connection control settings based on a client IP. These settings help to mitigate DoS (Denial of Service) and DDoS (Distributed Denial of Service) attacks.
  • File Access – a set of rules for controlling and managing the state of access rights, symbolic links and permission masks to the web server files.
  • CGI Settings – control Common Gateway Interface processes. Memory and process limits also serve as the default for other external applications if limits have not been set explicitly for those applications.
  • Access Denied Directories – directories that should be blocked from access. Add directories that contain sensitive data to this list to prevent accidentally exposing sensitive files to clients. Append a “*” to the path to include all sub-directories. If both “Follow Symbolic Link” and “Check Symbolic Link” are enabled, symbolic links will be checked against the denied directories.
  • Access Control – specifies what sub networks and/or IP addresses can access the server. At the server level, this setting will affect all virtual hosts. You can also set up access control unique to each virtual host at the virtual host level. Virtual host level settings will NOT override server level settings.

LiteSpeed Cache High-Performance

LiteSpeed Cache (LSCache) is included as a built-in, high-performance dynamic content acceleration feature in the LiteSpeed Web Server. The LSCache comes by default in Free Starter, Site Owner, Web Host, and legacy 8-CPU license. Web site dynamic content is accelerated by LSCache with features similar to mod_cache ones in Apache, but it is done by LiteSpeed efficient and highly customizable native implementation.

LSCache allows to avoid usage of an extra reverse-proxy layer required by add-on cache packages (such as Varnish) that consequently translated into higher efficiency of static assets in addition to handling of dynamic content.

It is strictly recommended using specially designed plugins for your application that coincide with one from this list. Otherwise, the LSCache can be enabled globally (not recommended) or for a specified virtual host.

Here we demonstrate how to enable LSCache for dynamic content of demo web site based on phpinfo() function usage.

As it is shown above, the environment created from Jelastic certified stack template has this function implemented in the index.php default web-page which is accessible by Open in Browser button.

Open it and then turn on the Developer tools by pressing F12 or Ctrl+Shift+i in case of Chrome web browser. See the Response Headers section for your website (virtual host).

litespeed web server response headers

You can observe there is no info regarding content caching.

To make it caching do the following:

1. Open Configuration File Manager, go to the root context directory of your virtual host (/var/www/webroot/ROOT directory in our case).

2. Then create New File and call it as .htaccess.

3. Add the following lines to the .htaccess file:

<IfModule LiteSpeed>

 RewriteEngine On

 CacheLookup on

 RewriteCond %{REQUEST_METHOD} ^HEAD|GET$

 RewriteRule .* – [E=Cache-Control:max-age=120]

</IfModule>

4. Save the changes, refresh the webpage of the website and take a look at Response Headers section once again.

litespeed web server response

The new line X-Litespeed-Cache: miss was added to the Response Headers that means the LSCache was enabled for the website (virtual host), but it’s not cached yet since we observe the miss as a status. In order to make it cached refresh the webpage one more time and take a look at X-Litespeed-Cache header.

litespeed web server cache header

Now cache status was changed to hit, that means the dynamic content was loaded from the cache of your virtual host.

The .htaccess config file can be complemented with many other directives that you consider relevant.

LiteSpeed WS Comparative Benchmark Test

In order to compare the LiteSpeed WS and other most popular web servers (Apache and NGINX) performance, you can do the benchmarking in a few minutes within Jelastic dashboard using ApacheBench (ab) utility as a workload source and simple php script as responding application.

1. Create three environments with the latest versions of Apache, NGINX and LiteSpeed Web Server, for example,
apache-php.vip.jelastic.cloud, nginx-php.vip.jelastic.cloud and litespeed-php.vip.jelastic.cloud

2. Create php script in web servers ROOT directories via Configuration File Manager as follows:

<?php echo “hello world”; ?>

litespeed web server config manager

3. Create a testing environment using the same Apache Web Server template which will be generating requests to measure web servers performance.

4. Open a terminal via Web SSH on the testing environment application server and run the following command for each destination environment, filtering command’s output by parameter Requests per second with a help of grep utility. This parameter indicates the number of requests the responding web server can serve in one second:

~$ ab -n 10000 -k -q -c 100 http://${env.domain}/hello.php | grep Requests

5. Finally, compare the results. The greater the number the better web server performance.

Obviously, the LiteSpeed WS is the unconditional leader.

Pricing

Being a commercial software, LiteSpeed Web Server requires the license to be installed. Specifically for Jelastic PaaS, there was created a more flexible pricing model for LiteSpeed servers that suits dynamic cloud environments. You can start with free licenses using up to 2 GB per environment. Then the price will depend on the tiers according to the RAM usage.

litespeed web server pricing

Note:

  • Pricing may vary depending on the country and chosen service provider. Herewith, all the account charges can be viewed via the Billing History in the dashboard.
  • Change Interval to hour in order to get better understanding you pay for.

litespeed web server billing history

Now you see how easy it is to get LiteSpeed WS up and running, as well as what performance increase you can get with it migrating from Apache or NGINX web server. High results make this solution a perfect choice for running applications like WordPress or Magento with heavy or variable load. This server is already integrated to the pre-packaged Magento that can be installed just in a click.

Explore the benefits of high performance and availability with cutting edge LiteSpeed Web Server hosted at Jelastic Multi-Cloud PaaS.

Subscribe to get the latest updates