Skip to content

Zlib: brotli compression is much slower than gzip #40220

Open
@csvan

Description

@csvan

Version

16.10.0

Platform

OSX, Linux (CentOS 8)

Subsystem

zlib

What steps will reproduce the bug?

Full test suite: https://github.com/timotejroiko/zlib-benchmark (not authored by my team, but is comprehensive and reaches the same conclusion).

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Brotli compression with zlib should be on par with gzip

What do you see instead?

Brotli compression is much slower than gzip

Additional information

We have replicated this issue on live production systems where we use zlib to perform over-the-air compression of static files. The (proprietary) code checks the accept-encoding header on client requests, and compresses accordingly (using default zlib settings).

The system originally prioritised brotli over gzip since the former is more efficient, however, we noticed a massive spike in CPU usage when doing so. After switching priority to gzip, CPU usage was at a minimum - for the same files and general load conditions.

We do not know if this is expected, but the discrepancy in performance is so large that it effectively disqualifies brotli for a large number of use cases involving high workloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceIssues and PRs related to the performance of Node.js.zlibIssues and PRs related to the zlib subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions