Discover Centmin Mod today
Register Now

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

    5
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    12:37 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

    43,117
    9,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,112
    Local Time:
    4:37 AM
    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.
     
    • Like Like x 1
  3. jessuppi

    jessuppi New Member

    5
    4
    3
    Apr 17, 2019
    Ratings:
    +4
    Local Time:
    12:37 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

    43,117
    9,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,112
    Local Time:
    4:37 AM
    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 effect 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
    • Like Like x 1
  5. pamamolf

    pamamolf Premium Member Premium Member

    3,697
    357
    83
    May 31, 2014
    Ratings:
    +688
    Local Time:
    8:37 PM
    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 :(
     
    • Agree Agree x 1
  6. eva2000

    eva2000 Administrator Staff Member

    43,117
    9,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,112
    Local Time:
    4:37 AM
    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
     
    • Like Like x 2