Skip to content

Make brotli compression quality configurable #942

Closed

Description

@vdusek

PR #927 added optional brotli request-body compression. The brotli quality is currently hardcoded to 6 in src/apify_client/http_clients/_base.py:

_brotli_compress = functools.partial(brotli.compress, quality=6)

Quality 6 is a reasonable default (better ratio than gzip, much lower CPU than brotli's max quality 11), and it's documented as such in docs/02_concepts/13_compression.mdx. But it's not tunable: users who want maximum compression (quality 11) for bandwidth-bound workloads, or a lower quality to save CPU, currently have no way to change it.

Proposal

Expose the compression quality as a client-level configuration option instead of relying only on the hardcoded value. Points to decide during design:

  • A client parameter (e.g. on ApifyClient / the HTTP client) to override the brotli quality, defaulting to the current 6.
  • Whether to also make the gzip compression level configurable for symmetry.
  • Whether to let users force a specific algorithm rather than relying purely on import-based auto-detection (br when brotli is importable, gzip otherwise) — the current behavior flips to brotli whenever the brotli package is present in the environment, even if it was pulled in transitively.

Context

Activity

  1. added
    enhancement
    t-tooling
    on Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementt-tooling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions