Repository navigation
feat: compress API request bodies with zstd at level 1 - #35
Merged
Merged
Conversation
apify-client 0.17 adds ZstdHttpCompressor, and the Apify API now accepts Content-Encoding: zstd: dataset pushes, key-value records and request queue batch adds read back unchanged, and a record stored zstd-encoded is served decoded to readers that don't accept zstd. On real push bodies zstd 1 is about 2.5x faster than brotli 1, for bodies about 6% smaller. Configuration::api_brotli_quality becomes api_zstd_level (1 to 19, default 1). The reqwest backend honours HttpRequest::follow_redirects with a second client that follows none, and sends the new PATCH, OPTIONS and TRACE methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
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.
This upgrades apify-client to 0.17.0, which adds
ZstdHttpCompressor, and switches every API client of the SDK from brotli at quality 1 to zstd at level 1.Why: on 2,000 real push bodies from the Instagram profile scraper (median 37 KB), zstd at level 1 takes 97 µs per body, against 242 µs for brotli at quality 1. Its output is also about 6% smaller (0.140 of the input against 0.149). Compression is about 9.6% of a profile run's CPU.
The API takes it. I checked this on the platform with client 0.17:
Content-Encoding: zstdall read back unchanged.Accept-Encoding: zstd, so the JS SDK, the Console andcurlstill get plain JSON.Changes:
Configuration::api_brotli_qualitybecomesapi_zstd_level(1 to 19, default 1). An invalid level keeps the client's own compression (brotli), as before.ReqwestBackendnow honoursHttpRequest::follow_redirectsthrough a second shared reqwest client that follows no redirects, as the client's own backend does.PATCH,OPTIONSandTRACEmethods.follow_redirects: falsegets the 302, and the fake API oftests/storage.rsnow decodes zstd bodies.docs/allowed-differences.mdis updated.zstdcompiles a C library (zstd-sys), so building the SDK now needs a C compiler. Rust's Docker images and the CI runners have one.Generated by Claude Code