Skip to content

DRIVER-409 Add gzip request compression - #54

Merged
dkropachev merged 7 commits into
mainfrom
dk/driver-409-request-compression
Jul 16, 2026
Merged

DRIVER-409 Add gzip request compression#54
dkropachev merged 7 commits into
mainfrom
dk/driver-409-request-compression

Conversation

@dkropachev

@dkropachev dkropachev commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Jira: https://scylladb.atlassian.net/browse/DRIVER-409
Closes #22

Summary

  • Add a Config::request_compressor API and built-in GzipRequestCompressor, disabled by default unless configured.
  • Make HttpRequestCompressor::Compress stream from request input to compressed output and return false when the compressor chooses to leave the request uncompressed.
  • Keep the small-request policy inside GzipRequestCompressor: it skips bodies smaller than 1024 bytes by default, with GzipRequestCompressor(0) available to compress every body.
  • Compress AWS SDK DynamoDB request bodies only for requests routed to known Alternator endpoints, setting Content-Encoding and exact Content-Length so compressed requests are not chunked.
  • Preserve header optimization interop by keeping compression-required headers in the optimized allowlist, while skipped requests remain uncompressed with their original body and Content-Length.

Configuration API

scylladb::alternator::Config cfg;
cfg.request_compressor =
    std::make_shared<scylladb::alternator::GzipRequestCompressor>();

Custom compressors implement:

class HttpRequestCompressor {
public:
    virtual ~HttpRequestCompressor() = default;

    [[nodiscard]] virtual std::string ContentEncoding() const = 0;
    [[nodiscard]] virtual bool Compress(
        std::istream& input,
        std::uint64_t input_size,
        std::ostream& output) const = 0;
};

Returning false leaves the request uncompressed, which lets implementations make their own size or content-policy decision without adding more config fields.

Testing

  • git diff --check
  • cmake -S . -B build-check -DALTERNATOR_CLIENT_CPP_ENABLE_AWS=OFF
  • cmake --build build-check -j$(nproc)
  • ctest --test-dir build-check --output-on-failure
  • cmake -S . -B build-no-zlib-check -DALTERNATOR_CLIENT_CPP_ENABLE_AWS=OFF -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=ON
  • cmake --build build-no-zlib-check -j$(nproc)
  • ctest --test-dir build-no-zlib-check --output-on-failure

AWS adapter unit and integration tests were added for request compression, small-body skip behavior, and header optimization interop, but could not be compiled locally because this environment does not have AWSSDK with the dynamodb component installed. Confirmed with cmake -S . -B build-aws-check -DALTERNATOR_CLIENT_CPP_REQUIRE_AWS=ON.

@dkropachev
dkropachev merged commit ec4fe97 into main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have an configuration to enable HTTP request compression

1 participant