openresty / lua-resty-upstream-healthcheck

Health Checker for Nginx Upstream Servers in Pure Lua
515 stars 134 forks source link

many upstream problem #73

Closed lemon9921010 closed 4 years ago

lemon9921010 commented 4 years ago

about 100 upstreams , healthcheck does not work 2 shm zones , 100m dict

rainingmaster commented 4 years ago

@Lnsh Hi, could you post more detail here, such as your lua code, nginx config file and logs. Beside, how to judge it does not work?

lemon9921010 commented 4 years ago

[root@nginx01 script]# for uptream in grep upstream /usr/local/openresty/nginx/conf/upstream.conf | awk '{print $2}'; do echo $uptream; done | wc -l 104 local ok, err = hc.spawn_checker{ shm = 'healthcheck', -- defined by 'lua_shared_dict' upstream = ... type = 'http',

        http_req = 'GET /status HTTP/1.0\r\nHost: healthcheck.nxin.com\r\n\r\n',
                -- raw HTTP request for checking

        interval = 2000,  -- run the check cycle every 2 sec
        timeout = 1000,   -- 1 sec is the timeout for network operations
        fall = 3,  -- # of successive failures before turning a peer down
        rise = 2,  -- # of successive successes before turning a peer up
        valid_statuses = {200, 302, 301,401,402,403, 404},  -- a list valid HTTP status code
        concurrency = 10,  -- concurrency level for test requests
    }

... ...

       local ok, err = hc.spawn_checker{
        shm = 'healthcheck',  -- defined by 'lua_shared_dict'
        upstream = ...
        type = 'http',

        http_req = 'GET /status HTTP/1.0\r\nHost: healthcheck.nxin.com\r\n\r\n',
                -- raw HTTP request for checking

        interval = 2000,  -- run the check cycle every 2 sec
        timeout = 1000,   -- 1 sec is the timeout for network operations
        fall = 3,  -- # of successive failures before turning a peer down
        rise = 2,  -- # of successive successes before turning a peer up
        valid_statuses = {200, 302, 301,401,402,403, 404},  -- a list valid HTTP status code
        concurrency = 10,  -- concurrency level for test requests
    }

    if not ok then
        ngx.log(ngx.ERR, "failed to spawn health checker: ", err)
        return
    end
}

upstream ,can not get requests delete about 20 upstreams either from head or tail it works

lemon9921010 commented 4 years ago

openresty1.13.6 also update 1.15.8 test, the same problem

rainingmaster commented 4 years ago

@Lnsh

Hi, have you get some log in your error log? And could you post them here.

Maybe you can set your lua_max_running_timers and lua_max_pending_timers bigger and try, I think maybe there is some limit in the timer of nginx.

lemon9921010 commented 4 years ago

No error log I try set lua_max_running_timers and lua_max_pending_timers , thx

lemon9921010 commented 4 years ago

Unluckily, it does not work too, conf like this lua_max_pending_timers 2048; lua_max_running_timers 1024;

lemon9921010 commented 4 years ago

log: init_worker_by_lua error: init_worker_by_lua:1688: main function has more than 200 local variables delete local it works, 3q