Nginx throughput capacity drops
Thank you for providing this tool! Already used in production environment。 Use it to process gzip body data。 But the processing speed drops by 60% after enabling。 Close the decompression program, processing capacity 600MB/S,but after turning it on, 200MB/S。 Do you have good suggestions and ways? This is lua code: ngx.ctx.max_chunk_size = tonumber(ngx.var.max_chunk_size) #:10kb ngx.ctx.max_body_size = tonumber(ngx.var.max_body_size) #:1M
function inflate_chunk (stream, chunk) return stream(chunk) end
function inflate_body (data) local stream = require("zlib").inflate() local buffer = "" local chunk = ""
for index = 0, data:len(), ngx.ctx.max_chunk_size do chunk = string.sub(data, index, index + ngx.ctx.max_chunk_size - 1) local status, output, eof, bytes_in, bytes_out = pcall(stream, chunk) buffer = buffer .. output end
return buffer end
local content_encoding = ngx.req.get_headers()["Content-Encoding"] if content_encoding == "gzip" then ngx.req.read_body() local data = ngx.req.get_body_data()
if data ~= nil then local new_data = inflate_body(data) ngx.req.set_body_data(new_data) end end
Are you measuring processing capacity in MB/S before deflation or after? How is the CPU before/after deflation? How does this compare to mod_deflate? https://www.webperformance.com/library/reports/moddeflate/