Want to subscribe to topics you're interested in?
Become a Member

PHP Is LSAPI (Litespeed) faster than PHP-FPM (Nginx, etc) or not?

Discussion in 'Nginx and PHP-FPM news & discussions' started by jessuppi, Feb 10, 2020.

  1. jessuppi

    jessuppi New Member

    7
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    1:14 AM
    I wanted to begin a public discussion on the performance of LSAPI, the SAPI for PHP created by the folks at Litespeed, since I noticed @eva2000 mention it below...

    https://www.lowendtalk.com/discussi...espeed-vs-nginx-make-use-of-your-idle-servers
    ...along with perhaps taking a more general look at Litespeed compared with LEMP stacks.

    In that thread you had stated that LSAPI was faster than PHP-FPM when measuring head-to-head processing of dynamic PHP scripts (uncached).

    Since you are one of the top "benchmark" guys on the web these days, and probably more unbiased that most anyone else that's shilling for Litespeed, I'm wondering if you might expand more on if this is just your assumption based on the architecture or if you have done actual benchmarks and case studies on LSAPI compared with PHP-FPM specifically?

    Furthermore, since LSAPI only supports Litespeed/Apache servers and not Nginx, it would seem that any comparison is a bit limited when trying to compare directly with LEMP stacks. For example, when you pair FastCGI (cache) with PHP-FPM on Nginx servers, it is a bit different than PHP-FPM + FCGI on Apache servers.

    ...which sort of begs the question, is comparing uncached PHP somewhat pointless? And where does OPcache factor in, esp. with OPcache file cache?

    Although I haven't run my own benchmarks, it is my current understanding that LSAPI could be the only feature from Litespeed that they could honestly claim is faster than a LEMP stack server at this stage (as of LS version 5.x). But again, it seems more a theoretical than practical claim.


    Lastly, I was surprised to see you being so "polite" about their http2benchmark website... it seems beyond obvious that they tried to make the website look like an unbiased third party, and then purposefully used an Nginx config that was setup very poorly vs. Litespeed in their tests, naturally resulting in their own Litespeed software performing faster... a joke, really.

    Ref: https://www.reddit.com/r/selfhosted...speed_servers_seem_like_a_marketing_scam_are/
    Ref: https://www.reddit.com/r/Wordpress/comments/f07rf2/litespeed_servers_seem_like_a_marketing_scam_are/

    On a related note, it would seem that Litespeed, cPanel, and CloudLinux are getting a little bit too cozy with each other these days, if you know what I mean... that said, it is interesting that cPanel still seems to promote and prefer PHP-FPM over LSAPI (though maybe not for much longer?).

    Cheers and thanks for all that you do ~
     
    Last edited: Feb 10, 2020
  2. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Note Litespeed/OpenLitespeed are on my to do list for Centmin Mod integration eventually see Centmin Mod dev dashboard at centminmod/centminmod. Not there yet as I am perfecting Centmin Mod Nginx first. Then will work on perfecting Centmin Mod Litespeed/OpenLitespeed. Goal is to have the most optimal configuration for either Nginx/PHP-FPM or Litespeed/OpenLitespeed/LSAPI PHP provided by Centmin Mod.

    From actual real world production from my high traffic paying consulting clients + synthetic benchmarks. Regardless at high traffic levels both Nginx and Litespeed/OpenLitespeed requiring further tuning beyond out of box installation anyway. High traffic is as in 500,000+ unique IP visitors/day and/or 15,000+ PHP related requests/second.

    yes testing Litespeed + LSAPI PHP vs Centmin Mod Nginx + PHP-FPM will inherently test the web server too. Litespeed LSAPI is more closely integrated with Litespeed server hence partially better performance. Nginx's PHP-FPM is a separate server maintained and developed by PHP and not Nginx folks.

    uncached meaning without a cache layer in front of PHP which offloads PHP load elsewhere. OPcache is included in tests as it still part of PHP. When I mean uncached I mean without varnish cache, cloudflare cache everything page rule, php-fpm fastgci_cache of dynamic PHP, litespeed cache of dynamic PHP or any other caching layer which moves the load away from PHP itself with exception of Opcache. So testing PHP + Opcache code as is which is what out of the box Litespeed LSAPI PHP or Nginx's PHP-FPM are when not additionally configured for higher level caching mentioned.

    Yes their http2benchmark site doesn't have a optimised Nginx configuration and partly that probably is due to inexperience with nginx and I am sure there's a commercial incentive to not be as thorough in investing time into acquiring more Nginx know-how. Some may argue that is a valid comparison as alot of folks are the same - noob or not well versed in configuring Nginx/PHP-FPM so end up with same configurations being compared/tested.

    I wrote about it at https://www.webhostingtalk.com/showthread.php?t=1775139 along with doing a fork for early http2benchmark code. The forked http2benchmark code results are further down in that thread which do show Litespeed 5.4 is faster than Litespeed 5.3 and Nginx official RPM installs configured more optimally by me (not Centmin Mod nginx still though so Nginx results there would be slower than Centmin Mod Nginx). Alot of my earlier tests of my own were with Litespeed 5.3 and lower and Centmin Mod Nginx which was alot closer and sometimes better for static files at least. But Litespeed 5.4 is new and faster than Litespeed 5.3.
    and from https://www.webhostingtalk.com/showthread.php?t=1775139&p=10169960#post10169960
    If you use cPanel and want better than Apache performance, then it is highly recommended to use Litespeed as it natively supports cPanel as a plugin which is what my cPanel based clients would use. Nginx on cPanel isn't that well integrated.
     
  3. jessuppi

    jessuppi New Member

    7
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    1:14 AM
    Thanks for your detailed response.

    By chance will you publish your LSAPI vs. PHP-FPM benchmarks? With the disclaimer that the "full stack" always matters in the end, it would still be interesting to see how their "uncached" processing compares.

    But at the end of the day, I'm just not sure how relevant uncached PHP performance is. PHP market share is still big really only because of CMS software like WordPress, which inherently is going to have multiple caching layers (e.g. CloudFlare/CDN, FastCGI Cache or LS Cache, Redis object cache, etc).

    Only in rare situations (usually at the sub-CMS level, etc) would uncached PHP loading happen regularly these days such as a very complex and dynamic website where an abnormal amount of unique queries is happening... I know that Centmin Mod is popular about discussion forum servers, but besides that, I'm not sure of common cases?

    It would also be nice to compare e.g.:
    • Litespeed + LSAPI
    • Litespeed + PHP-FPM
    • Apache + LSAPI
    • Apache + PHP-FPM
    • Nginx + PHP-FPM

    The whole point is that LSAPI is really meant for shared hosting in the end, to reduce per-user resource usage and things like that which have been a stability issue with PHP-FPM pools over the years...

    Since Nginx is really not "aimed" at shared hosting, a theoretical LSAPI of sorts for Nginx does not really make sense unless companies like cPanel got serious about support, etc.

    And as far as LSWS + LS Cache itself, I'd love to hear more input from Apache admins how much it differs from using Apache2 with Varnish cache and events enabled...
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    most of the results are with real world clients so I wouldn't be publishing or benchmarking needlessly on live client servers. But uncached PHP still has relevance as whenever you have a cache miss on any front end cache layer, it hits PHP and depending on your workload patterns cache misses can be determining factor as to how well your server stack setup handles overall load. So you may measure average throughput or latency response times, but real testing also measures minimum, maximum and 95-99% percentile throughput and latency response times and that usually highlights how effective non-cached PHP performance is i.e. the cache misses.

    Litespeed can be configured for non-shared hosting outside of cPanel, Plesk, DirectAdmin too so isn't just for shared hosting. Just not many folks are familiar with Litespeed's ins and outs to configure it standalone.

    pure technical optimised stack in order of best to worse would be
    • Litespeed + LSAPI - especially as Litespeed 5.4 > 5.3
    • Nginx + PHP-FPM
    • Apache + LSAPI PHP held back by Apahce
    • Apache + PHP-FPM
    However, Nginx and Apache has varying install methods and configuration so you can't lump all Nginx and Apache servers into the same class. For example, Centmin Mod Nginx is faster than distro out of box default Nginx provided binaries and Centmin Mod PHP-FPM built binaries are faster than distro or yum repo provided PHP-FPM built binaries see example in PHP 7.4 vs 7.3 vs 7.2 vs 7.1 vs 7.0 benchmarks.
     
    Last edited: Feb 11, 2020
  5. pamamolf

    pamamolf Premium Member Premium Member

    4,068
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    9:14 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    I vote for Nginx and Open Litespeed for Centminmod :)

    Apache seems for me very slow and a bit outdated :(
     
  6. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod will eventually support both free OpenLiteSpeed as well as paid Litespeed web servers with LSAPI PHP :)

    Apache these days only makes up 1.2% of all my servers with 1.8% cpanel (33% of that apache and 67% litespeed), 0.6% directadmin and rest of the 96.4% is Centmin Mod based :D
     
  7. Web Guy

    Web Guy New Member

    5
    0
    1
    Apr 8, 2020
    Ratings:
    +2
    Local Time:
    6:14 PM
    I'm not sure if I should make a new post but this topic is what I'm trying to find out as well, so I thought I'd reply.
    Sorry if that's breaking some forum rule.

    I run a web dev company and only have average server knowledge.
    I use a VPS with CloudLinux 7, WHM, Cpanel and have recently moved to use LiteSpeed (from Apache).

    While the speed is great for LiteSpeed cached pages, the non-cached pages (where PHP has to serve the page) is quite bad (TTFB of 2-4 seconds).

    The hosting company I use says I'm currently using suphp PHP handler, which is supposed to be a bit slow.

    I've been researching today and found 3 options for my PHP;
    LSAPI
    PHP-FPM
    FastCGI

    Litespeed of course recommends LSAPI (PHP LSAPI Overview - LiteSpeed Technologies) but now that I've read about PHP-FPM, I can't decide which is the best option. I guess FastCGI is another option.

    Basically, I need a fast PHP handler. Most of my sites are fairly small, so the LiteSpeed server page cache will help but I do have some complex sites (large ecommerce etc) which will need PHP to serve the pages (for logged in shop users etc).

    Does anyone have advice regarding the best/fastest handler please? I won't be setting it up, my hosting company will do this but they're not overly keen on recommending a particular handler (for whatever reason).

    EDIT: I just found a post saying that LSAPI doesn't really provide much of a performance boost for WHM servers Using lsapi in WHM
    Now I'm really confused!

    EDIT2: If it makes a difference, my VPS has 2vCPUs and 8GB ram. I'm mentioning in case one of the handlers needs loads of recourses to work.
     
    Last edited: Apr 8, 2020
  8. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    did you read my above posts as the answer to your question is literally written in this thread's posts :)
     
  9. Web Guy

    Web Guy New Member

    5
    0
    1
    Apr 8, 2020
    Ratings:
    +2
    Local Time:
    6:14 PM
    Thanks very much for the reply!

    I did have a read but I have to admit a lot of it went over my head. I'm really good at what I do but my knowledge of the server side of things is quite limited.
    In laymen terms, for a VPS such as mine (2vCPUs, 8GM with CloudLinux, WHM, Cpanel, LiteSpeed webserver) which is currently using suphp ad the PHP handler, do you think LSAPI or PHP-FPM is a better choice (maybe that's impossible to answer with the limited data I've presented)?

    Please take into account my hosting company is, umm, less than ideal regarding optimizing the installations of things like PHP-FPM (which I've read takes more tweaking to get right...not sure if that's correct or not). I think they'll just activate the modules in Easy Apache.

    So I think I'll have to choose whatever is the easier option to get working, as long as it's quicker than suphp, I'm happy. I guess I'm thinking, if I'm going to be paying for a LiteSpeed license, I may as well use the support I get as a paying customer to help them tweak the LSAPI install.

    Interested in your thoughts. Thanks.

    PS. I realise that in an ideal world I would move over to this Centmod option but that's not possible in my situation.
     
  10. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Simple if using Litespeed/OpenLitespeed use LSAPI PHP and if using Apache or Nginx use PHP-FPM. For Litespeed, wouldn't make any sense not using faster LSAPI as Litespeed is a paid product with tech support as well built into their license price.
     
  11. Web Guy

    Web Guy New Member

    5
    0
    1
    Apr 8, 2020
    Ratings:
    +2
    Local Time:
    6:14 PM
    Thanks! That makes complete sense. :)
     
  12. jessuppi

    jessuppi New Member

    7
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    1:14 AM
    Interesting case study (and unbiased technical benchmarks) there... seems like even more evidence that LSAPI (and thus Litespeed overall) is not faster than PHP-FPM / Nginx.

    Unless @eva2000 can share detailed benchmarks and explain his conclusion better, I've yet to see any evidence anywhere that Litespeed (or the LSAPI module itself) is ever faster than PHP-FPM / Nginx. The entire claim just seems completely concocted for marketing purposes as stated on those Reddit threads, and their company seems to (rightly?) assume that most users won't second-guess their claims since they target the low-end shared hosting market.

    I posted here as well:
    https://stackoverflow.com/questions...s-showing-litespeed-faster-than-nginx-servers

    One thing is for sure, Litespeed will continue to cannibalize the Apache market share unless and until the DevOps world becomes more mainstream (e.g. moves away from cPanel obsession) and/or cPanel's support for Nginx becomes serious.
     
    Last edited: Apr 11, 2020
  13. eva2000

    eva2000 Administrator Staff Member

    53,140
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    4:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Already showed some php benchmarks in above linked/below quoted WHT threads and scripts are there to run your own tests or you can devise your own benchmarks for your own specific needs. Anyway end of the day, use whatever you're comfortable with and with whatever you're familiar with knowledge wise :)
     
  14. Web Guy

    Web Guy New Member

    5
    0
    1
    Apr 8, 2020
    Ratings:
    +2
    Local Time:
    6:14 PM
    Just to give people an update, in case it helps others. I went with LSAPI (actually the CloudLinux mod_lsapi module). I was having a problem with awful TTFB on non server cached pages (around 4s but that was on a heavy WooCommerce site). Turned out the main issue was the LSPHP process was being killed and the slowness was that process spooling up again.
    I increased the PHP 'Max Idle Time' (in LiteSpeed config, actually to 24 hours...I know that probably seems way too long..I'm not recommending anyone else does this, I'm just testing it) and now getting well under 2s TTFB for non cached pages (which I still think I can improve but that's another topic).
    I know there's a danger of a resource problem, with lots of LSPHP processes running but I'll never have 100's of sites, so I'm hoping it won't be an issue.

    For lighter / non-eCommerce sites, mostly cached pages will be served (which I've found to have amazing performance in Litespeed). And the non-cached pages are really quick as well (around 500ms to 1s TTFB).

    Anyway, I hope that helps if anyone else is in the same situation.
     
  15. ahmed

    ahmed Active Member

    361
    49
    28
    Feb 21, 2017
    Ratings:
    +63
    Local Time:
    8:14 AM
    any updates for LiteSpeed and centmin? can I just install it manually? google have a Litespeed already in house but I don't want to move from centmin, any update for that?
     
  16. Atrix

    Atrix Member

    37
    13
    8
    Oct 7, 2018
    Ratings:
    +38
    Local Time:
    12:14 AM
    1.15.3
    MariaDB 10.1.36
    Wondering if this is anywhere near done, it sounds like a daunting amount of work but I can be patient.
     
  17. David Schargel

    David Schargel New Member

    26
    8
    3
    Feb 2, 2020
    Ratings:
    +18
    Local Time:
    11:14 PM
  18. rdan

    rdan Well-Known Member

    5,439
    1,397
    113
    May 25, 2014
    Ratings:
    +2,186
    Local Time:
    2:14 PM
    Mainline
    10.2
  19. jessuppi

    jessuppi New Member

    7
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    1:14 AM
    (Ignoring the thread-jacking going on here...)

    From that post, yet again we see bizarre comparisons between Litespeed and Nginx stacks... have so many syadmins really never heard of Nginx FastCGI caching? Comparing LS + LS Cache with Nginx + Redis (?) is like comparing apples to oranges, and is rather irrelevant in the end.

    Anyway I've yet to see any public benchmarks (or sensible methodology) comparing the PHP handlers themselves, which might be near impossible to do. OPcache (PHP) file cache should also be part of the conversation these days, too, which will make at least some of the PHP handler comparisons a moot point.

    I think it's safe to say for now that unless you are hosting highly dynamic discussion forum software, then there are not many reasons to consider using Litespeed instead of a LEMP stack. They add more bloat to your stack, require .htaccess files (and all associated stability concerns therein), and are aggressively pursuing a relationship with cPanel... all of these things, and their dishonest shilling around the web, make me very cautious, personally. In their defense, however, I think they should be commended for LSAPI, which is refreshing to see in an industry sometimes over-reliant on community maintainers, etc... for example, PHP-FPM was neglected a bit in the past.

    For the typical PHP-based CMS, this stack is still king IMO:

    Ubuntu + Nginx + FastCGI Cache + PHP-FPM + OPcache + OPcache file cache + MySQL/MariaDB

    ...with Redis and/or Memcached for object caching if needed for your site. If you want to go crazy, you could use a server with enough RAM memory and activate TMPFS to virtually eliminate disk I/O. Anyway these are the features I've been testing for SlickStack, but I always appreciate @eva2000 for his public feedback :)
     
    Last edited: Jan 18, 2021
  20. Atrix

    Atrix Member

    37
    13
    8
    Oct 7, 2018
    Ratings:
    +38
    Local Time:
    12:14 AM
    1.15.3
    MariaDB 10.1.36
    I can't comment on the stack testing as I don't really have the time to invest in it and I delegate that to those who do. However eva has tested a lot of stuff and I trust them, and used centminmod for years. I'm currently running litespeed setups for several clients and I'll tell you easily why I chose that. That doesn't mean the choice is mandatory nor do I have any interest in some pissing contest on the internet, but I think a litespeed version of centminmod would be really useful so I think it fair to say the reasons I chose it for some of my servers now.

    1) I run a lot of wordpress sites, and litespeed caching was hands down the most easy to setup and complete and hands free caching plugin I've ever tried. The one that comes with centminmod is decent but it doesn't come out of the box with a lot of features and as such it doesn't support things I need. The uses for some of these sites are heavily backend dependent and see more backend use than frontend use. I saw a reduction of several seconds on some pages in the backend using litespeed. What is even better than that (though that in itself is amazing) is the caching almost never needs cleared and it just works. Varnish could get to that point but it was hard to configure and a pain to maintain litespeed caching is not only faster in my experience it just freakin works. Their plugin has a ton of reviews with 5 stars for a reason imo.

    2) It has it's own admin built into the webserver, this is nice a lot of the time. I love command line and I love config files but sometimes it's nice to just have the webserver itself do all the checking and setup for me.

    3) It has extremely good debug logging and it's easy to figure out what is going wrong with it enabled. This probably exists for nginx and apache but I never did come across it and it's very obvious with litespeed. In general it's super accessible and easy to use and setup.

    4) Nginx I switched to reluctantly due to the speed benefits. I actually really loathe spending all the time I did to switch things that just worked with htaccess files and writing it in nginx config files instead and having to do that for tons of diff wordpress plugins. Then it wasn't stable at all. Because the configs would be written by ppl who like nginx but didn't get the testing and often you had to find it on stack overflow or write it yourself and it was just unreliable and untested a lot of the time. litespeed doesn't slow down due to how it processes and caches htaccess files which don't change most the time anyway. I find having them again SO amazing. It cuts out a lot of stupid work I had to do before just to use nginx.

    5) it's fully compatible (or at least mostly) with apache syntax. I only ever had to modify one rule. Most the time it works flawlessly.

    Overall it's faster, less maintenance, quicker results. I wish I knew about it sooner. The days of having to build my own server configs that support php-fpm on top of cpanel were gone when I found centminmod and I still think it's amazing. Cpanel is an absolute mess compared to centminmod. I'll keep supporting the project and hope a litespeed version sees the light of day because I do miss some of the scripts for centminmod that made life easier. Like just creating a vhost via command line. Just made less work for me, just because I know how to create a vhost in nginx or apache syntax doesn't mean I should be spending time doing it if a reliable script exists to do so instead.

    I think for non wordpress sites there's more reason to consider nginx. However from what I've seen for drupal 7 it only takes like 20 lines of config code documented already to get a lot of the features working so the possibility for it to work on anything is def there.

    I've seen some of the insane benefits that come with php 8 and speed. That might turn this entire discussion on it's head we'll have to see. Though I think it will be some time before all the modules I use are also on php 8 so it will be a moot point for me for quite a while.