Join the community today
Become a Member

123.09beta01 Updated Nginx zlib routine with optional Cloudflare zlib support

Discussion in 'Centmin Mod News' started by eva2000, Dec 17, 2017.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Centmin Mod 123.09beta01 has updated it's Nginx web server's zlib support (required for HTTP gzip support) to optionally support the performance forked Cloudflare zlib 1.2.8 version when SSE4.2 supported cpus are detected on the server. Cloudflare zlib performance fork details are outlined in their blog article here. Older benchmarks comparing Cloudflare zlib fork with standard zlib and Intel optimised zlib code is available here.


    Updated zlib workaround solution



    During the development and testing phase for integrating Cloudflare zlib support in Nginx, I came across a bug in how Centmin Mod's Nginx zlib routine is done for the current standard custom zlib 1.2.11 routine as well as for Cloudflare zlib 1.2.8 support. So made a revision in the Centmin Mod Nginx compilation/install code to fix this as well which you can see the commits dated Decemeber 15th & 16th at Commits · centminmod/centminmod · GitHub.

    The zlib workaround fix, involves only the next Nginx compile via centmin.sh menu option 4 to:
    • Remove the old zlib shared library install method used for Nginx zlib which also requires a once off service(s) restart for services which picked up the old zlib shared library install method. The service(s) restart ensures that those services fall back to the default system yum provided zlib shared library version (CentOS 7.x uses zlib 1.2.7 & CentOS 6.x uses zlib 1.2.3). These services that require a once of restart include, nginx, php-fpm, MariaDB MySQL, postfix, memcached, sshd, pure-ftpd etc. They will only restart services that are running, so if the service isn't running, it won't force a once off restart. When you run centmin.sh menu option 4 to recompile, upgrade or downgrade Nginx versions, you'll get a once off prompt just before the nginx version prompt outlining that service(s) restarts are necessary.
      Code (Text):
      Upgrade Note:
      This nginx recompile involves zlib changes which have one time
      service restarts including MariaDB MySQL restart to switch
      from custom zlib shared library back to system zlib library
      for services other than Nginx. Nginx will use custom zlib
      by itself while all other services will revert back to system
      zlib shared library
      
      Nginx Upgrade - Would you like to continue? [y/n] y
      
      Install which version of Nginx? (version i.e. type 1.13.7): 1.13.7
      
    • Ensures that only Centmin Mod Nginx uses the custom zlib 1.2.11 library or optional Cloudflare zlib 1.2.8 library.

    Suggestion


    1. As this once off next Nginx compile via centmin.sh menu option 4 involves many services being restarted automatically, you may want to schedule the Nginx recompile at an off peak / low traffic time of day ;)
    2. While the automated auto service restarts may pick up all services, sometimes the name listed in lsof output for the service is truncated so doesn't correspond with the service's actual name. So a service restart may be skipped. So the 100% to be sure method would be for a server reboot if you want to ensure all services which relied on zlib are now using the correct system yum provided zlib library.

    Relevant threads


     
  2. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Added another update to 123.09beta01 branch code as it seems Centmin Mod compiler cacher, ccache uses zlib shared library too so needs recompiling as well. Centmin Mod uses ccache compiler caching to speed up subsequent source compiled software - compilation speed can be improved by up to 80% faster than without compiler caching.

    Before fix old shared zlib library used /usr/local/lib/libz.so.1
    Code (Text):
    ldd $(which ccache)
            linux-vdso.so.1 =>  (0x00007ffc94bd7000)
            libm.so.6 => /lib64/libm.so.6 (0x00007f9dc2ed4000)
            libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f9dc2cbe000)
            libc.so.6 => /lib64/libc.so.6 (0x00007f9dc292a000)
            /lib64/ld-linux-x86-64.so.2 (0x00007f9dc3158000)
    

    After fix system yum provided zlib library used /lib64/libz.so.1
    Code (Text):
    ldd $(which ccache)
            linux-vdso.so.1 =>  (0x00007ffd1786b000)
            libm.so.6 => /lib64/libm.so.6 (0x00007f7b8eb1a000)
            libz.so.1 => /lib64/libz.so.1 (0x00007f7b8e904000)
            libc.so.6 => /lib64/libc.so.6 (0x00007f7b8e570000)
            /lib64/ld-linux-x86-64.so.2 (0x00007f7b8ed9e000)
    

    If you have already run the above updated code and missed recompiling ccache update, you can do it manually via the below commands in SSH as root user. Update ccache 3.4.1 is out too, so if 3.3.4 below doesn't work try 3.4.1 for cd into /svr-setup/ccache-3.4.1/
    Code (Text):
    export CC="gcc"
    export CXX="g++"
    cd /svr-setup/ccache-3.4.1/
    make clean
    ./configure
    make -j2
    make install
    

    Then to double check all source compiled binaries are using system yum provided zlib library = /lib64/libz.so.1
    Code (Text):
    for b in $(ls  /usr/local/bin); do if [[ "$(ldd "/usr/local/bin/$b" | grep libz.so)" ]]; then echo $b; ldd "/usr/local/bin/$b" | grep libz.so; fi; done
    
    ccache
            libz.so.1 => /lib64/libz.so.1 (0x00007fb407394000)
    memcached
            libz.so.1 => /lib64/libz.so.1 (0x00007f75b4ee6000)
    pcregrep
            libz.so.1 => /lib64/libz.so.1 (0x00007ffaf72d5000)
    php
            libz.so.1 => /lib64/libz.so.1 (0x00007efefe007000)
    php-cgi
            libz.so.1 => /lib64/libz.so.1 (0x00007ff75be08000)
    phpdbg
            libz.so.1 => /lib64/libz.so.1 (0x00007fe440d55000)
    siege
            libz.so.1 => /lib64/libz.so.1 (0x00007fbb7c5eb000)
    wget
            libz.so.1 => /lib64/libz.so.1 (0x00007f2ef9959000)
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  4. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    As part of the How to boost Centmin Mod LEMP stack performance guide, I did some benchmark comparisons for each of the supported Centmin Mod Nginx compiler build options for GCC 4.8.5, 5.3.1, 6.3.1, 7.2.1, 8.0 and Clang 3.4.2, 4.0.1, 5.0.1, 6.0.0 with the standard default Nginx Zlib library versus Cloudflare's Zlib performance fork library. I did load testing benchmarks using my own custom forked version of wrk load testing tool testing gzip compressed requests so as to properly test each Zlib library https://github.com/centminmod/wrk/tree/centminmod.

    As you can see, Cloudflare's Zlib performance fork library has around 22-29% better performance than the default Centmin Mod Nginx Zlib library performance which is compiled against Zlib v1.2.11 on CentOS 7.4.

    You can view the raw wrk benchmark numbers here.

    chart2.png


    table1.png
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  6. eva2000

    eva2000 Administrator Staff Member

    54,098
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:54 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
Thread Status:
Not open for further replies.