Skip to content

Compression opt-out, performance killer #96

@Zaczero

Description

@Zaczero

Most frameworks provide response compression as an opt-in. ConnectRPC-Python does not, and there is no easy way to opt out, which conflicts with my compression proxy. Adding to the issue, negotiate_compression is inefficient. It picks the first supported compression instead of the best one. For example, Google Chrome sends gzip, deflate, br, zstd where the ideal order of preference would be: zstd→br→gzip→deflate. ConnectRPC-Python picks gzip. And it uses the default settings, a compression level of 9 (https://docs.python.org/3/library/gzip.html#gzip.compress). This is a performance killer.

My feedback is that while ConnectRPC is an amazing piece of software, the compression layer is bad and it should be reworked or thrown away as it hurts more than it helps. I'm saying this because I've been solving very similar problems at https://github.com/Zaczero/pkgs/tree/main/starlette-compress (feel free to copy any piece of code you want; it's 0BSD).

My current workaround is to drop the Accept-Encoding header and compress when Content-Encoding is "identity". I may be open to contributing to connect-python if you point me in the right direction (if you have one), so I can understand what parts you are open to improving. I may find some additional things that need changing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions