Want more timely Centmin Mod News Updates?
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

    6
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    11:26 PM
    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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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

    6
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    11:26 PM
    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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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

    3,840
    377
    83
    May 31, 2014
    Ratings:
    +721
    Local Time:
    7:26 AM
    Nginx-1.17.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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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:
    4:26 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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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:
    4:26 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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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:
    4:26 PM
    Thanks! That makes complete sense. :)
     
  12. jessuppi

    jessuppi New Member

    6
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    11:26 PM
    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

    45,126
    10,269
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,915
    Local Time:
    2:26 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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:
    4:26 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

    350
    48
    28
    Feb 21, 2017
    Ratings:
    +61
    Local Time:
    6:26 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?