Closed asg5704 closed 3 years ago
Excellent analysis @AGarcia-Clarity, thank you!!!
With the caveat that I have no idea what effort is involved, I think HTTP/2 is something we should do anyway.
If we add brotli compression support, I'm guessing we're going to increase build times. I'd like to see us quantify what that difference is, for the brotli change alone. Because our build times are atrocious right now, and we are actively trying to reduce them.
Thank you @f1337. I would have to do more research but from my readings:
Mentioned that HTTP/2 could be a larger fix if we already have HTTP 1.1 optimizations in place. The beauty of HTTP/2 is that we do not have to get rid of HTTP/1.1 at all (because it will be around for at least another decade). Instead we could allow HTTP/1.1 to create an upgrade request via Upgrade
headers if the browser supports it.
It could increase build times depending on how we do the Brotli compression. There are two options Static compression (using webpack) and Dynamic compression which each have their pros & cons.
We would have to compress assets ahead of time during the build process and then they are uploaded to the S3 bucket. This option would increase build times however assets would be loaded quicker (latency reduced)
Compressing assets on-the-fly when they are requested from the browser. This option would NOT increase build times because creating & updating compressed versions of these assets doesn't need to be done. However the latency could take a hit if we set compression levels too high.
TBD at a later date.
RFC
I did some preliminary analysis of possible improvements that can be implemented to ensure assets are loaded efficiently on VA.gov. I am requesting comments, feedback, questions, etc of if these implementations can be implemented on our AWS S3 bucket using an nginx proxy.
Use Brotli compression to further reduce file sizes sent over the network on Amazon S3 buckets.
Why? Better file size compression. Brotli compression compared to GZIP:
The current sizes of bundled JS assets on the AWS S3 bucket are (102Kb, 102Kb, 299Kb, and 194Kb) respectively. Using Brotli these could become (87.7Kb, 87.7Kb, 257Kb, and 166.8Kb) respectively. 697Kb of data down to 599Kb (~100Kb)
Pros
Cons
Upgrade to HTTP/2 protocol
Why? Could drastically improve server latency for requests
Assets request from the AWS S3 bucket are currently served over HTTP 1.1, which only allows 6 TCP connections per origin. If there are more than 6 connections it places the requested files in a Queue to be resolved at a later time which why there is a lot of latency. By upgrading to the HTTP/2 protocol, we could benefit from its multiplexing capabilities (on a single TCP connection 🤯 ), compression, and prioritization it uses to reduce web page latency.
Pros
Cons