Open bradp-wordkeeper opened 3 months ago
One more detail that I meant to mention. The perf top
command shows the specific function call causing the overhead is CreateBackwardReferencesNH5.
I can add a ton more detail if needed too. :)
For context, this high CPU use occurred with Brotli comp levels as low as 4 and the Nginx and Brotli types config is the same list of supported MIME types. There is no reason that Zlib at level 6 should take substantially less CPU horsepower than Brotli at level 4.
Hi All,
We started seeing some odd CPU issues on 1 of our servers about 2 months ago and I'm digging for answers. The ultimate effect that we're seeing is that Nginx started using about 6x the power to serve the same number of requests on the same site as it did before.
Using
perf top
, I was able to determine that something in Brotli is causing this issue. Also, if I disable Brotli in the Nginx config and let it fall back to Gzip, CPU usage goes back to normal.The issue started while using Nginx 1.25.5 and we're on 1.27.0 now. We've also gone from Brotli 1.0.9 to 1.1.0. No change during upgrades or recompiles of Nginx, Brotli, or the ngx_brotli module either.
One more data point is that I ran a test in a Fedora 40 container and that seemed to solve the problem. I compiled Nginx in the Fedora container using the exact same settings and build process. Then I just stopped the normal instance of Nginx that we use and started up the containerized version in its place. The CPU went right back to normal during that test and that's with Brotli enabled, but I couldn't leave it like that for various reasons. The only difference being the underlying OS and libraries that it uses in the container, I guess.
So that all makes me think that it could be either a bug in the OS libraries somewhere or a bug in Brotli that only happens under certain conditions. This server OS is CentOS Stream 9.
Any ideas what could be causing this high CPU usage when using Brotli specifically?
Here is Nginx build info if that helps: