Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf(ext/fetch): improve decompression throughput by not using tower_http::decompression #25800

Conversation

magurotuna
Copy link
Member

@magurotuna magurotuna commented Sep 22, 2024

This commit improves the throughput when a Deno process is running as a proxy server that deals with compressed data from the upstream server.

We have seen a performance degradation since v1.45.2 when we run a HTTP server with Deno with a particular setting where it fetches compressed data from the upstream server and forwards it to the end client. After some investigation, it's turned out that tower_http::decompression causes this issue, and that this issue is resolved if we manually implement decompression logic using async-compression directly.

This figure shows how the performance changes for different versions (lower is better), and verifies this patch fixes the issue:

perf comparison

(See also https://github.com/magurotuna/deno_fetch_decompression_throughput for how this result was obtained)

Probably we could discover a potential bottleneck in tower_http, but given that manual implementation just takes less than 100 lines of code, it makes more sense to maintain our own code rather than depending on the third party, in my opinion.

Fixes #25798

@magurotuna
Copy link
Member Author

I just sent a patch to tower-http to fix the root cause of this performance issue: tower-rs/tower-http#521

Now I prefer to keep using tower_http::decompression instead of manually implementing a similar logic by directly using async-compression, because tower_http::decompression takes care of HTTP trailer but this PR doesn't, and it would require a lot more code if we wanted to handle it properly.

@magurotuna
Copy link
Member Author

Closing in favor of #25806

@magurotuna magurotuna closed this Sep 22, 2024
@magurotuna magurotuna deleted the magurotuna/perf-fetch-decompression branch September 22, 2024 17:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throughput of proxying compressed data with fetch and Deno.serve has deteriorated
1 participant