hi~ 春哥 救命啊
代码如下
ngx.header.content_type = "text/plain"
cache = ngx.shared.cache
_DIR = "/home/nginx/servers/lua/"
local parser = require "redis.parser"
dofile(_DIR .. "function.lua")
uid = 1000
ran = math.random(1,1000)
cache:set('ran:' .. uid,ran,3000)
while 1 do
local ut = cache:get('ran:' .. uid)
if ut ~= ran then
ngx.say('ut')
ngx.eof()
end
local req = parser.build_query({'rpush', 'some-key', 'some-value'})
local status,body = red_open(req)
local data = ""> local json = '{"e":1,"type":2,"title":"标题信息","msg":"内容信"}'
ngx.print(json)
ngx.flush()
ngx.sleep(20)
end
模拟了 1W http 长连接 因为 lua 代码里面用 while 1 do 所以 所以一直循环下去 所以一直hold住
现在发现个问题,就是查看 liunx 查看内存的时候 刚开始 1W 并发内存用了 1G 但是 随着时间内存越来越多
不知道这样的代码是不是有问题。是不是存在不合理的地方。。。。。。。。。。。。。。。。。。。。