呃,重点不在这里啦。。。
我为了简化演示这个过程而已,完全 copy https://github.com/agentzh/lua-resty-upload 的 example
重点在于,通过 vip post 总是 timeout ,而通过 real server post 都是正常的。
我再抓包,开 debug 看看
----
Regards
Hello Chan
On Jun 19, 2012, at 10:41 AM, Wendal Chen wrote:
>
>
> 在 2012年6月18日 下午11:08,Hello Chan <czb...@gmail.com>写道:
> hi, all
>
> 问题描述下:
> 使用 lua-resty-upload 处理 POST 的图片,有三台处理的机器,前面挂着 LVS 来跑。
> 用 curl 模拟 post 请求,直接 post 到三台,是没有问题的,但 POST 到 VIP 上,就出问题了,每次都是 lua socket read timed out
>
> 说说我的运行环境:
> 为了重现问题,我把实际运行环境简化了一下,以下:
>
> VIP : 192.168.1.4 , real server : 192.168.1.1/2/3 ,用 DR 模式
>
> location /post {
> default_type 'text/plain';
> content_by_lua_file 'lua/post.lua' ;
> }
>
> post.lua (基本 copy example 那个代码) :
> ------------------------------
> local upload = require "resty.upload"
> local cjson = require "cjson"
>
> local chunk_size = 1024 -- should be set to 4096 or 8192
> -- for real-world settings
>
> local form = upload:new(chunk_size)
>
> form:set_timeout(1000) -- 1 sec
>
> while true do
> local typ, res, err = form:read()
> if not typ then
> ngx.say("failed to read: ", err)
> return
> end
>
> ngx.say("read: ", cjson.encode({typ, res}))
>
> if typ == "eof" then
> break
> end
> end
>
>
> local typ, res, err = form:read() -- 前面都已经读完了,这里还读?!
>
> ngx.say("read: ", cjson.encode({typ, res}))
> ----------------------------------------
> 1)
> curl 模拟请求,这里的 test.txt size 为 40K:
>
> curl --form name=@test.txt http://192.168.1.1/post
> curl --form name=@test.txt http://192.168.1.2/post
> curl --form name=@test.txt http://192.168.1.3/post
>
> 均正常返回
> 请求 vip
> curl --form name=@test.txt http://192.168.1.4/post
> 读了几段 body 后,就爆
> failed to read: timeout
> 了
>
>
> 2)
> 尝试 size 小一点的文件,test2.txt size = 11K
>
> 结果都正常
>
>
> 3)
> 尝试不在内网测试
> 在一个很差的网络环境下测试,上传 40K 文件需要 4s 的地方,curl post 模拟,结果正常,没有 timeout 了。
>
>
>
>
> 各位,这种情况,有解吗??
>
>
> ----
> Regards
>
> Hello Chan
>
> --
> Wendal Chen
> GuangDong China
>
>