
Litespeed Web Server. What Is It?
- Written by John
- Nov 6th, 2015
For those that have never heard of Litespeed before, it is simply, a web server. There’s a bit more to it than that but in essence it rivals Apache and Nginx. Looking at Litespeed in depth it features HTTP/2, SPDY/3.1, 3 & 2, compatible with Apache configurations, high performance & security and much more. It is easily configurable with its own web interface.
How fast is it?
I can say that it is truly faster than Apache but is dependent upon your usage environment. However, Litespeed has done their own performance charts which have some great results with WordPress, not so great for Apache and Nginx though.
Integration with PHP
I was a little baffled, I must admit when trying to use PHP with Litespeed. PHP is somewhat built into Litespeed, well, more of integrated so you can tweak PHP as much as you want. The only downside with this is if you are going to run PHP software using a database then you will need to add extra configuration statements when going through the compiling process. As much as it is baffling you can work your way through it and get the best out of it. You can choose to have as much or as little extensions of PHP as you need.
What is truly great with the integration of PHP is it allows you to change PHP setups pretty easily, only needing to compile a new version. If it is a different version from what you have, ie, moving from version 5 to version 7, the only additional change that you need to make is pointing PHP to use PHP7 by default under Action -> Configuration -> Server -> Script Handling, edit PHP and change lsphp5 to lsphp7 and the locations of each PHP version, that’s it.
Caching
Litespeed allows you to add caching functionality to speed up the page loading times of your website. There are a few different types of caching software, but it depends on what PHP version you compile as not all are supported with all versions of PHP. I am currently using OPCache with PHP 5.6.15.
Just to put it into perspective for you, after enabling OPCache on PHP 5.6.14/15 on my web server which hosts a phpBB 3.0.14 forum, it allowed for a 153% increase in transactions to be carried out, allowing more traffic to flow through my server without impacting on performance.
The only stumbling block I found with this is you need to enable any caching in the php.ini file. In the newer versions of Litespeed the php.ini file does not exist in /usr/local/lsws/lsphp5/php/ so you need to copy it from the php build folder itself in location /usr/local/lsws/phpbuild/php-<PHPVersion>/php.ini-production. There is a development ini file but I use the production config on a production server. Once copied to the PHP folder you need to edit the file and place the corresponding extension for your caching system. You can see if it is enabled by using a phpinfo() script.
Upgrading php with Apache
Looking back at when I was using Apache and trying to upgrade PHP to a newer version, I found that I had too many different versions of dependencies which meant my PHP solution was getting very messy. Some bits were using the EPEL repository, some bits were using CentOS repository, there just wasn’t any continuity, and furthermore, because of this fragmentation errors were being thrown up all over the OS. This was one reason that pushed me to try out an alternative, especially one that is not massively used. At the same time, I was looking into the HTTP/2 standard and how it was designed. I came to learn that not many web server software had HTTP/2 integrated. Nginx is currently developing HTTP/2 into their product but there is no release date/cycle for Apache.
Benchmarking
I feel a little disappointed with Litespeed as when reading their website and other places on the net, overall, you get the feeling Litespeed is faster than Apache in pretty much any scenario. However, my performance charts do show otherwise, when using PHP in conjunction with a database.
All benchmarks have been running in a VM on my PC which has the below specs. The hardware for the VM is limiting so no usage factors on my host could be taken into account when benchmarking. I have also tried to use hardware that won’t introduce any bottlenecks, ie, SSD over HDD. Each benchmark was run three times, taking the results with the highest transaction rate.
Hello World TXT File – Simulating 100 users sending 1000 requests each
Intel Core i7 (4 cores)
20GB storage on a Mushkin SSD
4GB RAM
From the testing of the static file, you can see Litespeed is much quicker than Apache by default. In this scenario caching makes no difference for both Litespeed and Apache.
Litespeed with PHP 5.6 is 127% faster than Apache without caching enabled and 130% faster than Apache with caching enabled. Litespeed with PHP 7.0.0 is 125% faster than Apache with and without caching.
It seems that PHP 7.0 is currently working better for Apache than Litespeed. There is very little gain between PHP versions for Litespeed, 1% with both caching types. Please keep in mind that for this test a single static file was used.
phpbb 3.0.13 – Simulating 100 users sending 100 requests each
Intel Core i7 (4 cores)
20GB storage on Mushkin SSD
4GB RAM
I did find these results interesting. I thought that Litespeed would be as fast or slightly faster (worst case) than Apache. However, Apache has come out on top with OPCache enabled, please note that without caching enabled Apache is still as fast as Litespeed more or less.
Apache with PHP 5.6 & OPCache is 352% faster than itself without caching. It is also 318%-350% faster than Litespeed with the same PHP version, with and without caching enabled.
Apache with PHP 7.0.0 & OPCache is 454% faster than itself without caching. It is also 421%-444% faster than Litespeed with the same PHP version, with and without caching enabled.
Litespeed with PHP 7.0.0 with no caching is 128% faster than itself with PHP 5.6 and is 148% faster with caching.
Thoughts
I really like Litespeed, despite its learning curve. Once you know where all the settings are and what is required to configure Litespeed, you’re all set. My initial view of Litespeed was that it is was pretty much superior to Apache, at least. But during my time investigating and benchmarking both Apache and Litespeed, my view has changed. I will say that you need to understand and test each product in your use case before using it in a production environment. Each product functions differently and will be greater than the other depending on your environment, ie, database, static files, etc.
If your website uses SSL and you’re looking to use newer technologies like SPDY or even HTTP/2, Litespeed is the way forward. If you’re looking for performance over SSL functionality then I would advise testing for the correct product as stated above.
I would like to further test Apache and Litespeed in other scenarios with different PHP software and databases to see what would work best. I would also like to introduce Nginx as this is widely used and it is something that I have not used before.