Skip to content

Transparent compression of requests and responses #20128

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Dec 6, 2023

Conversation

jsteemann
Copy link
Contributor

@jsteemann jsteemann commented Nov 13, 2023

Scope & Purpose

Enterprise companion PR: https://github.com/arangodb/enterprise/pull/1410

  • Added options --compress-transfer and --compress-request-threshold to all client tools. These options can be used to enable transparent compression of the data that is sent between the client tools and the ArangoDB server.

    If the option --compress-transfer is set to true, the client-tools will add an extra HTTP header Accept-Encoding: deflate to all requests they make to the server. This allows the server to compress its responses before sending them back to the client tools.

    If the option is set to true, the client will also transparently compress their own requests to the server if the size of the request body (in bytes) is at least the value of the startup option --compress-request-treshold. The default value for this option is 0, which disables compression of the request bodies in the client tools. To opt in to sending compressed data, the option must be set to a value greater than zero. Request body compression will be performed using the deflate compression algorithm. The client tools will also add a Content-Encoding: deflate header to the request when the request body was compressed. As compression will use CPU cycles, it should be activated only in case the network communication between the client tools and the server is slow and there is enough CPU capacity left for the extra compression/decompression work. Furthermore, requests should only be compressed when they exceed a certain minimum size, e.g. 250 bytes. Too small requests are typically not compressible very well.

    Request compression is only supported for HTTP/1.1 and HTTP/2 requests, but not when using the VST protocol.

  • Added startup option --http.compress-response-threshold to the ArangoDB server. The value of this specifies the threshold value (in bytes) from which on response bodies will be sent out compressed by the server.

    The default value for this option is 0, which disables sending out compressed response bodies. To enable compression, the option should be set to a value greater than 0. The selected value should be large enough to justify the compression overhead. Too small response bodies are typically not well compressible.

    Regardless of the value of this option, response body compression will only happen in case the client advertised that it expects a compressed response body by sending an Accept-Encoding: gzip or Accept-Encoding: deflate header with its request. If that header is missing, no response compression will be performed by the server. As compression will use CPU cycles, it should be activated only in case the network communication between the server and clients is slow and there is enough CPU capacity left for the extra compression/decompression work. work. Furthermore, responses should only be compressed when they exceed a certain minimum size, e.g. 250 bytes. Response compression is only supported for HTTP/1.1 and HTTP/2 responses, but not when using the VST protocol.

  • 💩 Bugfix
  • 🍕 New feature
  • 🔥 Performance improvement
  • 🔨 Refactoring/simplification

Checklist

  • Tests
    • Regression tests
    • C++ Unit tests
    • integration tests
    • resilience tests
  • 📖 CHANGELOG entry made
  • 📚 documentation written (release notes, API changes, ...)
  • Backports
    • Backport for 3.11: -
    • Backport for 3.10: -

Related Information

* Added options `--compress-transfer` and `--compress-request-threshold` to
  all client tools.
  These options can be used to enable transparent compression of the data
  that is sent between the client tools and the ArangoDB server.

  If the option `--compress-transfer` is set to `true`, the client-tools
  will add an extra HTTP header `Accept-Encoding: deflate` to all requests
  they make to the server. This allows the server to compress its responses
  before sending them back to the client tools.

  If the option is set to `true`, the client will also transparently compress
  their own requests to the server if the size of the request body (in bytes)
  is at least the value of the startup option `--compress-request-treshold`.
  The default value for this option is `0`, which disables compression of the
  request bodies in the client tools. To opt in to sending compressed data,
  the option must be set to a value greater than zero.
  Request body compression will be performed using the deflate compression
  algorithm. The client tools will also add a `Content-Encoding: deflate`
  header to the request when the request body was compressed.
  As compression will use CPU cycles, it should be activated only in case the
  network communication between the client tools and the server is slow and
  there is enough CPU capacity left for the extra compression/decompression
  work. Furthermore, requests should only be compressed when they exceed a
  certain minimum size, e.g. 250 bytes.
  Too small requests are typically not compressible very well.

  Request compression is only supported for HTTP/1.1 and HTTP/2 requests,
  but not when using the VST protocol.

* Added startup option `--http.compress-response-threshold` to the ArangoDB
  server. The value of this specifies the threshold value (in bytes) from
  which on response bodies will be sent out compressed by the server.

  The default value for this option is `0`, which disables sending out
  compressed response bodies. To enable compression, the option should be
  set to a value greater than 0. The selected value should be large enough
  to justify the compression overhead. Too small response bodies are typically
  not well compressible.

  Regardless of the value of this option, response body compression will only
  happen in case the client advertised that it expects a compressed response
  body by sending an `Accept-Encoding: gzip` or `Accept-Encoding: deflate`
  header with its request. If that header is missing, no response compression
  will be performed by the server.
  As compression will use CPU cycles, it should be activated only in case the
  network communication between the server and clients is slow and there is
  enough CPU capacity left for the extra compression/decompression work.
  work. Furthermore, responses should only be compressed when they exceed a
  certain minimum size, e.g. 250 bytes.
  Response compression is only supported for HTTP/1.1 and HTTP/2 responses,
  but not when using the VST protocol.
@jsteemann jsteemann added this to the devel milestone Nov 13, 2023
@jsteemann jsteemann requested review from a team as code owners November 13, 2023 18:46
@cla-bot cla-bot bot added the cla-signed label Nov 13, 2023
@jsteemann jsteemann marked this pull request as draft November 13, 2023 18:47
@jsteemann jsteemann marked this pull request as ready for review November 30, 2023 09:27
@neunhoef neunhoef merged commit 75d05f3 into devel Dec 6, 2023
@neunhoef neunhoef deleted the feature/compression-support branch December 6, 2023 10:12
markuspf pushed a commit that referenced this pull request Dec 6, 2023
* Transparent compression of requests and responses

* Added options `--compress-transfer` and `--compress-request-threshold` to
  all client tools.
  These options can be used to enable transparent compression of the data
  that is sent between the client tools and the ArangoDB server.

  If the option `--compress-transfer` is set to `true`, the client-tools
  will add an extra HTTP header `Accept-Encoding: deflate` to all requests
  they make to the server. This allows the server to compress its responses
  before sending them back to the client tools.

  If the option is set to `true`, the client will also transparently compress
  their own requests to the server if the size of the request body (in bytes)
  is at least the value of the startup option `--compress-request-treshold`.
  The default value for this option is `0`, which disables compression of the
  request bodies in the client tools. To opt in to sending compressed data,
  the option must be set to a value greater than zero.
  Request body compression will be performed using the deflate compression
  algorithm. The client tools will also add a `Content-Encoding: deflate`
  header to the request when the request body was compressed.
  As compression will use CPU cycles, it should be activated only in case the
  network communication between the client tools and the server is slow and
  there is enough CPU capacity left for the extra compression/decompression
  work. Furthermore, requests should only be compressed when they exceed a
  certain minimum size, e.g. 250 bytes.
  Too small requests are typically not compressible very well.

  Request compression is only supported for HTTP/1.1 and HTTP/2 requests,
  but not when using the VST protocol.

* Added startup option `--http.compress-response-threshold` to the ArangoDB
  server. The value of this specifies the threshold value (in bytes) from
  which on response bodies will be sent out compressed by the server.

  The default value for this option is `0`, which disables sending out
  compressed response bodies. To enable compression, the option should be
  set to a value greater than 0. The selected value should be large enough
  to justify the compression overhead. Too small response bodies are typically
  not well compressible.

  Regardless of the value of this option, response body compression will only
  happen in case the client advertised that it expects a compressed response
  body by sending an `Accept-Encoding: gzip` or `Accept-Encoding: deflate`
  header with its request. If that header is missing, no response compression
  will be performed by the server.
  As compression will use CPU cycles, it should be activated only in case the
  network communication between the server and clients is slow and there is
  enough CPU capacity left for the extra compression/decompression work.
  work. Furthermore, responses should only be compressed when they exceed a
  certain minimum size, e.g. 250 bytes.
  Response compression is only supported for HTTP/1.1 and HTTP/2 responses,
  but not when using the VST protocol.

* fix compilation of mocks

* fix compilation of tests

* fix tests

* transparently uncompress in arangosh as well

* fix test error

* fix test

* fix cluster-internal request decompression

* adjust compression limits to cover even more cases

* added startup option

* add some test for compression

* some updates

* fix test expectations

---------

Co-authored-by: Max Neunhöffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants