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

    32,250
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    5:46 PM
    Nginx 1.13.x
    MariaDB 5.5
    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

    32,250
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    5:46 PM
    Nginx 1.13.x
    MariaDB 5.5
    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. RoldanLT

    RoldanLT Well-Known Member

    4,067
    983
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,366
    Local Time:
    3:46 PM
    1.11
    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

    32,250
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    5:46 PM
    Nginx 1.13.x
    MariaDB 5.5
    Yeah you'd disable that in xenforo so ngx_brotli can serve brotli compressed files in xenforo instead of gzip compressed.
     
  5. RoldanLT

    RoldanLT Well-Known Member

    4,067
    983
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,366
    Local Time:
    3:46 PM
    1.11
    10.2
    Yeah its either cloudflare zlib or brotli.
    I'll prefer brotli for now.
     
  6. eva2000

    eva2000 Administrator Staff Member

    32,250
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    5:46 PM
    Nginx 1.13.x
    MariaDB 5.5
    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

    2,974
    274
    83
    May 31, 2014
    Ratings:
    +484
    Local Time:
    9:46 AM
    Nginx-1.13.x
    MariaDB 10.1.x
    Working :)

     
    • Like Like x 1
  8. pamamolf

    pamamolf Well-Known Member

    2,974
    274
    83
    May 31, 2014
    Ratings:
    +484
    Local Time:
    9:46 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

    32,250
    7,165
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,892
    Local Time:
    5:46 PM
    Nginx 1.13.x
    MariaDB 5.5
    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