fix(mrt): improve Brotli streaming performance - #635
Draft
clavery wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
end()compressed outputWhy
Node's implicit Brotli quality 11 is optimized for offline compression. On a production-like 1.6 MB Storefront Next PLP response, it consumed seconds of Lambda time and buffered useful compressed output until the response completed. This also affects traffic through an upstream CDN because the CDN requests Brotli/Gzip from MRT before passing through or transforming the response for the visitor.
Controlled warmed A/B measurements using the same application bundle showed:
The compressed response grew from approximately 102 KB to 125 KB (about 23%) in exchange for eliminating roughly three seconds of response time and restoring progressive delivery. A local compression-only benchmark of the same 1.6 MB document improved from 1,641 ms at quality 11 to 9.45 ms at quality 6.
Validation
pnpm --filter @salesforce/mrt-utilities test:agent— 559 passingpnpm --filter @salesforce/mrt-utilities typecheck:agentpnpm --filter @salesforce/mrt-utilities lint:agentpnpm --filter @salesforce/mrt-utilities format:checkpnpm --filter @salesforce/mrt-utilities buildCompanion change
Storefront Next currently bundles a separate copy of this streaming adapter. The companion draft PR applies and tests the same fix there: commerce-emu/storefront-next#2648.