Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx throughput capacity drops #55

Open
feiniao886 opened this issue Jun 7, 2021 · 1 comment
Open

Nginx throughput capacity drops #55

feiniao886 opened this issue Jun 7, 2021 · 1 comment

Comments

@feiniao886
Copy link

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

@brimworks
Copy link
Owner

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants