Skip to content
Permalink
Browse files

revert ngx_brotli auto enable for intel skylake cpus in 123.09beta01

- Previously auto enabled ngx_brotli when intel skylake cpus were detected https://community.centminmod.com/threads/enable-nginx-brotli-module-on-intel-skylake-newer-cpus-in-123-09beta01.16553/ but that was under a flawed assumption that intel skylake cpus accelerated broti compressed http requests compared to gzip compressed http requests. The acceleration didn't come from intel skylake cpus but from an ngx_brotli configuration setting update did at https://community.centminmod.com/threads/only-use-brotli-compression-for-files-greater-than-64kb-in-123-09beta01.15951/ which changed brotli_min_length from 1000 to 65536 bytes so that Brotli compression is only used for files greater than 64KB when NGXDYNAMIC_BROTLI='y' and NGINX_LIBBROTLI='y' set https://community.centminmod.com/threads/nginx-config-suggestions.15950/#post-68317. The incorrect assumption was that brotli_min_length from 1000 to 65536 bytes change would switch to gzip compression if file was under 65536 bytes in length and only brotli compress files greater than 65536 bytes. When in fact what happens is that any files under 65536 bytes will end up without any form of compression and not switch back to gzip. So when you test brotli encoded requests for files under 65536 bytes, ngx_brotli serves them uncompressed instead of the flawed assumption that it will fallback to gzip. This meant that benchmarks on intel skylake cpus which happen to test files less than 65536 bytes ended up serving the file uncompressed which meant it's performance was better than compared gzip compressed encoded http requests for the same file.
- When brotli_min_length was changed back from 65536 bytes to 1400 bytes, then files under 65536 bytes and over 1400 bytes were then properly brotli compressed for brotli encoded http requests were made. However, the performance throughput was about 1/5th of gzip compressed performance in terms of requests/s throughput for on the fly dynamic brotli vs gzip.
- As such this commit update corrects some of the incorrect assumptions by first changing brotli_min_length back from 65536 bytes to 1400 bytes so that files under 65536 are properly brotli compressed again instead being served uncompressed and leaves ngx_brotli enabling up to end user to optionally enable again https://community.centminmod.com/threads/how-to-use-brotli-compression-for-centmin-mod-nginx-web-servers.10688/ and disables ngx_brotli by default otherwise.
- You can always reduce the brotli compression level default from 5 to 4 by manually editing the settings in /usr/local/nginx/conf/brotli_inc.conf and restart nginx service to improve brotli requests/s throughput by ~90%. This comparatively improves brotli on the fly compression throughput performance in terms of requests/s from 1/5th the speed of gzip to 1/4th the speed of gzip. So brotli on the fly performance is still slower than gzip but still improved. However, resulting brotli compressed files maybe slightly larger in some instances than gzip compressed file as seen below for jquery file bit larger but index.html bit smaller compressed file.
  • Loading branch information...
centminmod committed Feb 21, 2019
1 parent 0d3f604 commit 4e9f1e67b4f92e0de45e4a2b2f7edd3d30fd34d6
Showing with 8 additions and 8 deletions.
  1. +6 −6 centmin.sh
  2. +1 −1 inc/brotli.inc
  3. +1 −1 inc/nginx_configure.inc
@@ -26,7 +26,7 @@ DT=$(date +"%d%m%y-%H%M%S")
branchname='123.09beta01'
SCRIPT_MAJORVER='1.2.3'
SCRIPT_MINORVER='09'
SCRIPT_INCREMENTVER='098'
SCRIPT_INCREMENTVER='099'
SCRIPT_VERSIONSHORT="${branchname}"
SCRIPT_VERSION="${SCRIPT_VERSIONSHORT}.b${SCRIPT_INCREMENTVER}"
SCRIPT_DATE='31/03/2019'
@@ -1070,11 +1070,11 @@ fi
# auto enable nginx brotli module if Intel Skylake or newer cpus exist
# newer cpus allow brotli compressed nginx files to be served faster
# https://community.centminmod.com/posts/70527/
if [[ "$(grep -o 'avx512' /proc/cpuinfo | uniq)" = 'avx512' ]]; then
NGXDYNAMIC_BROTLI='y'
NGINX_LIBBROTLI='y'
NGINX_BROTLIDEP_UPDATE='y'
fi
# if [[ "$(grep -o 'avx512' /proc/cpuinfo | uniq)" = 'avx512' ]]; then
# NGXDYNAMIC_BROTLI='y'
# NGINX_LIBBROTLI='y'
# NGINX_BROTLIDEP_UPDATE='y'
# fi

###############################################################
# The default is stable, you can change this to development if you wish
@@ -384,7 +384,7 @@ ngxbrotli_download() {
cat > "/usr/local/nginx/conf/brotli_inc.conf" <<EIF
brotli on;
brotli_static on;
brotli_min_length 65536;
brotli_min_length 1400;
brotli_buffers 1024 8k;
brotli_comp_level 5;
brotli_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
@@ -2024,7 +2024,7 @@ if [[ "$NGINX_LIBBROTLI" = [yY] && "$(uname -m)" = 'x86_64' ]]; then
cat > "/usr/local/nginx/conf/brotli_inc.conf" <<EIF
brotli on;
brotli_static on;
brotli_min_length 65536;
brotli_min_length 1400;
brotli_buffers 1024 8k;
brotli_comp_level 5;
brotli_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;

0 comments on commit 4e9f1e6

Please sign in to comment.
You can’t perform that action at this time.