local upload = require "resty.upload"
local cjson = require "cjson"
function read_post_args()
ngx.say("byebye")
local chunk_size = 4096
local form, err = upload:new(chunk_size)
form:set_timeout(500)
local args = {}
local upload_file = false
local file_content = nil
local name = nil
local filename = nil
while true do
local typ, res, err = form:read()
if not typ then
ngx.say("faild to read: ", err)
end
if typ == "header" then
if res[1] ~= "Content-Type" then
--name, filename= my_get_filename(res[2])
--if filename ~= nil then
upload_file = true
file_content = ''
--else
-- args[name] = nil
--end
end
elseif typ == "body" then
if upload_file == true then
file_content = file_content .. res
else
args[name] = res
end
--ngx.say(res)
elseif typ == "part_end" then
if upload_file == true then
upload_file = false
end
--ngx.say("part_end")
elseif typ == "eof" then
break
end
end
return args , file_content
end
a, f = read_post_args()
ngx.say('finish2')
就是这样一个简单的代码, 我用laodrunner 做的压力测试, loadrunner设置了带宽为200k/s, 当loadrunner模拟一个用户上传文件, 就出现啦cup占用100%的问题
在 2012年12月12日星期三UTC+8下午1时31分16秒,lhmwzy写道:
连个代码都没有,别人不好替你诊断问题
在 2012年12月12日 上午11:41,kindy
<kin...@gmail.com>写道:
或者,你可以提供个最小化的代码用例?这样好让别人复现问题。
2012/12/12 cheng zhou
<cheng...@gmail.com>
没有后端服务, 所有处理都是在nignx里面完成的
在 2012年12月12日星期三UTC+8上午11时31分25秒,kindy写道:
你后端服务的日志有什么显示?upload 过程中,有调用什么 web service 么?
2012/12/12 cheng zhou
<cheng...@gmail.com>
大家好: 我在使用
lua-resty-upload模块做了一个文件上传的服务,在做大并发的测试的时候, 会出现nignx工作进程cup占用率100%的情况, 并且客户端访问失败,
查看nignx日志 有以下错误日志
2012/12/11 10:15:19 [error] 21833#0: *189262 lua tcp socket read timed out, client: 10.20.77.120, server: localhost, request: "POST /dumpserver/dumpfile.php HTTP/1.0", host: "10.20.68.210"
大家有碰到类似的情况吗, 这种问题出现的原因 是这个模块的bug 还是我自己的代码有问题?
--
- - - - - - - - - - - -
林青(Kindy Lin)
--
- - - - - - - - - - - -
林青(Kindy Lin)