136 points · by nailer · 8y ago · 80 comments
One of our devs just returned from a conference super excited about brotli. I'm the ops guy and want to try to support excitement, so I spent the better part of 2 days setting up an experiment, but I was skeptical. I'd been keeping my eye on brotli for years.
I first went out and looked for some existing evaluations of brotli, and found years old write-ups, one from Cloudflare from 2015, and another but I can't remember the details there. They both concluded that brotli wasn't ready yet, but they were also old...
Our stack uses Apache on Ubuntu 16.04, and the first stumbling block was that the Apache version on 16.04 is just a bit before the mod_brotli was added. So I used Ansible to spin up an 18.04 web server which did have the right version of Apache. But, apache is built without brotli support. So I ended up having to build my own custom packages, which went fairly smoothly.
We have one particular asset that right now we would like to speed up. It is a big JSON data structure. The dev did some testing and found that his 350K data-set (with gzip) ended up as 320K with brotli.
Maintaining our own custom Apache packages, and possibly having to upgrade our entire stack from 16.04 to 18.04, plus resolve known problems with OS packages that we've seen in 18.04, for a <10% compression gain, for our cherry-picked "best example for brotli wins"?
Our decision was that if we could have just turned it on via changes to the Apache configs, we would have done it. But as it is, it's not worth it for us to do.
YMMV.
We didn't do any before/after testing to see how much data it saved our users but the small tests we've done in the office showed around a 2-5% size reduction for our static assets which was great to see for all the effort of toggling a switch.
(I used to work on mod_pagespeed)
I know how to build my stack, it's encoded in Debian packages all around the Internet.
Another alternative is exploring h2o/caddy as a web server replacement.
Brotli is fine if you can precompress static files on a prep server or desktop.
It's unprofessional and unscientific to evaluate compression codecs without measuring how much CPU and memory they use. Brotli is a disappointment, coming 20 years after gzip. In 20 years we should expect something better than Brotli, something that is better optimized for modern CPUs, vectorized by default, and with a much better dictionary.
However, zstd doesn't have the browser support that brotli does. So you can't easily replace brotli with zstd for web use.
Timeline: Zstandard was released August 31, 2016. By that point, Firefox, Chrome, and Opera already had Brotli support. Safari and Edge got it shortly afterwards.
We serve small to medium sized businesses for our customer base in NZ.
Although I am not surprised: the Edge UI is buggy and the browser engine has its problems with sites too. And we have put a lot of work into ensuring Edge works properly for our clients.
Original post below.
>
Author here. This was submitted with:
'You can't use Brotli for dynamic content' and other horses**t (2018)
Odd the title was changed, you can see from the timestamp I spent yesterday updating it for 2018 (brotli is more of a big deal now iOS users can use it). Also the original title highlighted the very specific point that a lot of what is written about brotli online is incorrect. Most HN users are grown ups and have handle a starred-out swear word. Oh well.The title as it stands now is meaningless, because it applies equally to nearly any pair of compression algorithms.
> Brotli can compress faster than gzip and still produce smaller files
Huh?
> For dynamic content, we'll use 4, which still produces smaller responses but takes less time to compress than gzip or brotli on a higher setting.
Oh if you compare to gzip max. But who runs gzip max? Gzip 6 gives decent low cost compression. Gzip 9 is barely smaller but much slower.
Algorithms have their sweet spots. Brotli (small), LZMA (fast), gzip (somewhere in between).
Knowing nothing about my clients, bandwidth, or dynamism, I can turn on gzip without really a second thought.
What puzzles me though... How much of this 1.1MB is really needed? You can do form validation with HTML5. I don't see any other candidate on their front page. So instead of getting a 14% advantage, what about pushing it to 100% or so?
If you want a pleasant experience, you can’t use HTML form validation by itself. You need some added JavaScript.
(I am not defending over a megabyte of JavaScript. I like to do such things from scratch and optimise for size, and all the functionality that I see on that page looks like it’d comfortably fit in under ten kilobytes of JavaScript. The CSS can probably also be decimated. But these things only happen that way if you value such performance, and few do—perhaps justifiably, perhaps not.)
CertSimple is a full dashboard and application that does a lot of crypto in the browser which requires quite a lot of code.
Sure, there are probably gains to be had with code splitting and lazy loading, but those get significantly more complex and can cause issues for codebases that aren't setup to take advantage of it from the start.
And improvements are improvements. This was a blog post showing you how and why to implement brotli, not a request for how to improve page loading speed for their application specifically.
> the front page of CertSimple is 242 K gzipped, and would be 1.1MB uncompressed!
Of course the full app is a completely different thing.
Author here: no. The app is the front page.
/blog is a seperate AMP based site and tiny. Search 'discify' in this thread for a breakdown of what's in the module.
Mike, I’m afraid you have bigger problems than inefficient compression...
We use https://github.com/131/discify to analyse this and should be able to cut down a little further once the URL spec is more widely implemented.
animation:-amp-start 8s steps(1,end) 0s 1 normal bothI don't know specifically what amp.js is doing there with the animation but since the entire purpose of AMP is performance, I'm sure there's a solid motivation behind it.
Perf is always fun to optimise, but we're got features customers want that we need to work on first!
One of the best benchmark about web compression including brotli + different gzip compatible libraries:
Compression ratios give information about the contents of a message. Hence, it seems to make sense to only compress static content from a security standpoint.
“Maximum” is good because it handles a common use case. When you’re running a CLI tool, you’re much more likely to be processing static assets which are served many times. So “maximum” is a good guess of what the user wants.
I'd especially like to use Brotli because it has good support in modern browsers (pretty much everything except IE11) and would be good replacement for gzip (which should be disabled for HTTPS).
?
Please explain.
There are workarounds / mitigations with various effectiveness, but disabling compression when TLS is used is the simple way to prevent the attack.
[0] https://tools.ietf.org/html/draft-pironti-tls-length-hiding-...