Learn about Centmin Mod LEMP Stack today
Become a Member

Beta Branch add CLOUDFLARE_ZLIBPHP variable to use Cloudflare zlib fork for PHP compiles

Discussion in 'Centmin Mod Github Commits' started by eva2000, Jan 24, 2018.

  1. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    add CLOUDFLARE_ZLIBPHP variable to use Cloudflare zlib fork for PHP compiles

    - optional not enabled by default CLOUDFLARE_ZLIBPHP='n' when enabled and set CLOUDFLARE_ZLIBPHP='y' in persistent config file /etc/centminmod/custom_config.inc prior to PHP recompiles via centmin.sh menu option 5, will switch PHP-FPM usage of zlib from system zlib version to performance forked Cloudflare zlib library which has already been show to improve Nginx zlib compression performance by at least 22-29% 123.09beta01 Updated Nginx zlib routine with optional Cloudflare zlib support

    Continue reading...

    123.09beta01 branch

     
    • Winner Winner x 2
  2. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Enable variable by adding it to persistent config file /etc/centminmod/custom_config.inc prior to php compiles via centmin.sh menu option 5
    Code (Text):
    CLOUDFLARE_ZLIBPHP='y'
    

    run centmin.sh menu option 5 to recompile PHP version specifying exact php version you want i.e. 5.6.33, 7.0.27, 7.1.13 or 7.2.1 etc.

    Once compiled exit centmin.sh menu via option 24 and verify that PHP has been compiled with Cloudflare zlib library.

    You can check the following:

    php module info reports zlib version = 1.2.8 in SSH
    Code (Text):
    php --ri zlib
    
    zlib
    
    ZLib Support => enabled
    Stream Wrapper => compress.zlib://
    Stream Filter => zlib.inflate, zlib.deflate
    Compiled Version => 1.2.8
    Linked Version => 1.2.8
    
    Directive => Local Value => Master Value
    zlib.output_compression => Off => Off
    zlib.output_compression_level => -1 => -1
    zlib.output_handler => no value => no value
    

    that php-config --configure-options command in SSH shows listing for --with-zlib-dir=/usr/local/zlib-cf or not enabled you will see --with-zlib in it's place
    Code (Text):
    php-config --configure-options
    --enable-fpm --enable-opcache --enable-intl --enable-pcntl --with-mcrypt --with-snmp --enable-embed=shared --with-mhash --with-zlib-dir=/usr/local/zlib-cf --with-gettext --enable-exif --enable-zip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=lib64 --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --with-vpx-dir=/usr --with-t1lib=/usr --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx --disable-fileinfo --with-ldap --with-ldap-sasl --with-config-file-scan-dir=/etc/centminmod/php.d --with-xsl CC=ccache CFLAGS=-O3 -m64 -march=core2 -pipe CXX=ccache CXXFLAGS=-O3 -m64 -march=core2 -pipe
    

    using ldd command to check if PHP is using cloudflare zlib shared library at /usr/local/zlib-cf/lib64/libz.so.1 if not use system /lib64/libz.so.1
    Code (Text):
    ldd $(which php) | grep libz
            libz.so.1 => /usr/local/zlib-cf/lib64/libz.so.1 (0x00007eff6d36a000)
    
     
  3. rdan

    rdan Premium Member Premium Member

    4,292
    1,040
    113
    May 25, 2014
    Ratings:
    +1,498
    Local Time:
    10:37 AM
    Mainline
    10.2
    Opz I think it's time I set this back to enable:
    As I have it disabled for several months/years already.
     
  4. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Yeah you'd disable that in xenforo so ngx_brotli can serve brotli compressed files in xenforo instead of gzip compressed.
     
  5. rdan

    rdan Premium Member Premium Member

    4,292
    1,040
    113
    May 25, 2014
    Ratings:
    +1,498
    Local Time:
    10:37 AM
    Mainline
    10.2
    Yeah its either cloudflare zlib or brotli.
    I'll prefer brotli for now.
     
  6. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    You'd have to test to see which is faster brotli compressed files or cloudflare zlib. I suspect brotli would be smaller compressed files but slower versus cloudflare zlib larger compressed files but faster.

    For cloudflare zlib for Nginx zlib usage I did benchmark zlib compression levels 1-9 to see how it faired in terms of latency and speed for wrk load tests.
    Code (Text):
    for l in {1..9}; do
    sleep 5;
    echo -e "\ntest gzip_comp_level $l";
    sed -ie "s|gzip_comp_level .*|gzip_comp_level $l;|" /usr/local/nginx/conf/nginx.conf | grep gzip_comp_level
    ngxrestart >/dev/null 2>&1;
    echo "wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';"
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
    done;
    sed -ie "s|gzip_comp_level .*|gzip_comp_level 5;|" /usr/local/nginx/conf/nginx.conf | grep gzip_comp_level
    

    results as followed
    Code (Text):
    test gzip_comp_level 1
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     2.97ms    1.95ms  45.32ms   81.68%
    --
    Requests/sec:  70084.78
    Transfer/sec:    132.00MB
    
    test gzip_comp_level 2
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.16ms    2.64ms  64.11ms   77.59%
    --
    Requests/sec:  68376.01
    Transfer/sec:    127.68MB
    
    test gzip_comp_level 3
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.03ms    1.76ms  38.16ms   77.48%
    --
    Requests/sec:  67470.92
    Transfer/sec:    125.28MB
    
    test gzip_comp_level 4
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.42ms    2.08ms  63.73ms   83.98%
    --
    Requests/sec:  59970.39
    Transfer/sec:    109.24MB
    
    test gzip_comp_level 5
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.72ms    2.20ms  53.49ms   77.04%
    --
    Requests/sec:  55239.34
    Transfer/sec:     99.93MB
    
    test gzip_comp_level 6
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.78ms    2.37ms  61.54ms   83.31%
    --
    Requests/sec:  54516.21
    Transfer/sec:     98.68MB
    
    test gzip_comp_level 7
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.81ms    2.37ms  75.30ms   77.88%
    --
    Requests/sec:  54188.74
    Transfer/sec:     98.09MB
    
    test gzip_comp_level 8
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.88ms    2.74ms  81.36ms   80.85%
    --
    Requests/sec:  54206.85
    Transfer/sec:     98.12MB
    
    test gzip_comp_level 9
    wrk-cmm -t3 -c200 -d5s --breakout -H 'Accept-Encoding: gzip' -s scripts/setup.lua --latency http://localhost/ 2>&1 | egrep -A1 'Thread Stats|Requests/sec';
      Thread Stats   Avg      Stdev     Max   +/- Stdev
       Latency     3.70ms    2.36ms  60.68ms   75.73%
    --
    Requests/sec:  55295.88
    Transfer/sec:    100.09MB
    

    Would need to do similar tests for ngx_brotli enabled nginx with Accept-Encoding: br to see how ngx_brotli compression fairs.

    Edit: for ngx_brotli would need to test on HTTPS enabled site as brotli doesn't work on non-HTTPS. So more retesting would be needed.
     
  7. pamamolf

    pamamolf Well-Known Member

    3,117
    295
    83
    May 31, 2014
    Ratings:
    +530
    Local Time:
    5:37 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Working :)

     
    • Like Like x 1
  8. pamamolf

    pamamolf Well-Known Member

    3,117
    295
    83
    May 31, 2014
    Ratings:
    +530
    Local Time:
    5:37 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Confused on that :)

    Didn't know that they do the same thing.....

    So if i use Cloudflare and have there enable Brotli do i benefit to use on my server the Cloudflare Zlib for Nginx and Phpfpm?
     
  9. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    will still benefit as you speed up the communication and respond time between cloudflare and your backend origin (Centmin Mod LEMP stack server) :)
     
    • Informative Informative x 1
  10. Itworx4me

    Itworx4me Premium Member Premium Member

    84
    9
    8
    Mar 14, 2017
    Ratings:
    +11
    Local Time:
    7:37 PM
    Nginx 1.13.X
    MariaDB 10.1.X
    I tried to goto /etc/centminmond/custom_config.inc and that file doesn't exsist. Any idea why it doesn't. Running Beta Centmin.

    Thanks,
    Itworx4me
     
  11. Sunka

    Sunka Well-Known Member

    1,018
    280
    83
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +458
    Local Time:
    4:37 AM
    Nginx 1.15.0
    MariaDB 10.2.15
    You have to create that file for the first time.
    Then you add custom variables in there at the time

    Code:
    nano /etc/centminmond/custom_config.inc
     
  12. Itworx4me

    Itworx4me Premium Member Premium Member

    84
    9
    8
    Mar 14, 2017
    Ratings:
    +11
    Local Time:
    7:37 PM
    Nginx 1.13.X
    MariaDB 10.1.X
    Best way to create the file is the touch command?
     
  13. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Nano editor command will open up an existing file or save a newly edited file with same command. Or use Centmin Mod command shortcut = customconfig to do the same see FAQ item 16

    Easiest way to edit configuration or any files on your server is via logging into your server via ssh and directly editing them using nano or vim linux text editors.

    For nano which you can read up more about nano here and here. For vim text editor read here and here and thread at WebPerf - Popular Vim Commands – a Comprehensive Vim Cheatsheet

    Also there's numerous online how to use guides for nano and vim you can search for via google :)
     
    • Like Like x 1
  14. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    10:37 AM
    Hi I just read this thread. From what I understand, it is okay to enable them as below for better performance?

    Code:
    NGXDYNAMIC_BROTLI='y'
    NGINX_LIBBROTLI='y'
    CLOUDFLARE_ZLIBPHP='y'
    What about Multi-threaded compression tools (pigz, pbzip2, lbzip2, plzip, p7zip)? There other cache available on CMM? What is the better combination for wordpress site? Thank you.
     
    Last edited: Feb 25, 2018
  15. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    yup - though brotli ones are better for page sizes but not necessarily for nginx scalability in terms of requests/s handling especially if you already have CLOUDFLARE_ZLIB='y' enabled
     
  16. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    10:37 AM
    Hi @eva2000

    What about Multi-threaded compression tools (pigz, pbzip2, lbzip2, plzip, p7zip)? There other cache available on CMM? What is the better combination for wordpress site?

    Thank you so much.
     
  17. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    no need for that menu option as centmin mod 123.09beta01 has installed most of the useful ones via yum already now

    for new questions/topics and wordpress caching post a new thread in Blogs & CMS usage or relevant forums ;)
     
  18. rc112

    rc112 Member

    124
    14
    18
    Sep 22, 2017
    Ratings:
    +15
    Local Time:
    10:37 AM
    Got it. Thank you so so much as always. :D
     
  19. anthony parsons

    anthony parsons Premium Member Premium Member

    77
    18
    8
    Feb 12, 2017
    Ratings:
    +22
    Local Time:
    1:37 PM
    Current yum stable
    10.1
    I found that adding this, my site page load got slower. So I removed it, and pages load snappier again.
     
  20. eva2000

    eva2000 Administrator Staff Member

    36,357
    7,983
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,292
    Local Time:
    12:37 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    interesting.. haven't really done scientific tests for this yet so mileage will vary.
     
..