Giter Club home page Giter Club logo

lua-resty-checkups's People

Contributors

8mao avatar huangnauh avatar lhanjian avatar oliveryunchang avatar realliusha avatar starsz avatar timebug avatar tokers avatar vinsonzou avatar yejingx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lua-resty-checkups's Issues

demo报错

我按照 demo进行操作,报这样的错误
2019/12/18 15:28:09 [error] 55676#12685090: init_by_lua error: init_by_lua:4: attempt to call field 'init' (a nil value)
stack traceback:
init_by_lua:4: in main chunk

下面是 配置文件片段

lua_package_path "/usr/local/etc/openresty/config.lua;;";
    lua_code_cache on;
    
    lua_shared_dict state 10m;
    lua_shared_dict mutex 1m;
    lua_shared_dict locks 1m;
    lua_shared_dict config 10m;

    init_by_lua_block {
        local config = require "config.lua"
        local checkups = require "resty.checkups.api"
        checkups.init(config)
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

	location /hehe {
	    default_type 'text/plain';
	    content_by_lua_block {
            ngx.say(package.path)
            ngx.say(package.cpath)
	    }
	}

下面是我的 package.path
image

下面是我的package的位置
image

我是通过 opm get upyun/lua-resty-checkups 来安装的
可以看出 这个库是位于 package.path里面的,但是 为啥会报错啊?

优化:获取 upstream 的机器策略

获取 upstream 的时候(extract_servers_from_upstrea)是否可以考虑如下优化?

  1. 获取 upstream 的机器列表时,应该排除标 down 的机器,
  2. 如果没有 primary 机器,可以考虑将 backup 机器加入列表。

is there any way to have runtime dynamic configuration?

Hi
I am developing a cdn api system (proxy server) and I need to add load balancer option by having heartbeat and ... it's important for me to have runtime data structure update (every 5 mins) but all I see is that we have to config our data structure just at the start time!
is runtime update possible now in lua-resty-checkups?

set_peer_down 是worker级别的行为,没看到同步到其他所有worker的逻辑?

看了下说明,,只有一个worker做 health check, 然后调用 upstream.set_peer_down;
但是 set_peer_down 是worker级别的行为,没看到同步到其他所有worker的逻辑? 这是bug吧?

https://github.com/openresty/lua-upstream-nginx-module#set_peer_down
Note that this method only changes the peer settings in the current Nginx worker process. You need to synchronize the changes across all the Nginx workers yourself if you want a server-wide change (for example, by means of ngx_lua's ngx.shared.DICT).

一个节点发生宕机会堵塞其他其他节点的心跳检查

目前心跳检查是串行的。一旦一个节点发生宕机(关机)或者节点不存在,SYN在第一次请求失败之后,会重新以时间倍数增长的方式发起请求,直到请求时间达到一分钟,才会进入下个节点的心跳检测。一旦多台节点同时宕机或者配置了多个不存在的节点,就会堵塞N * 60s的时间,以至于影响其他机子的心跳检测。

您好,这个能支持动态新增或删除upstream指令块吗?就是不需要在nginx.conf里面加

 upstream backend {
        server 0.0.0.0;
        balancer_by_lua_block {
            require "wario.balancer"
        }
    }

如上面的代码块,lua-resty-checkups提供的update和delete好像都是预先需要在nginx.conf里面声明了一个backend,才能去动态变更后段的servers,能不能连这个指令也能通过lua来创建呢?

因为我试过lua-resty-checkups的api是做不到的,不知道是不是姿势不对,希望能得到回复,谢谢

how can i use dynamic upstream with lua-resty-checkups

i want use lua-resty-checkups to realize a micro service gateway,this is my way:

  1. set upstream variable on set_by_lua
  2. set proxy_pass with upstream variable
    but, i find this way does not work, it throw a error : no resolver defined to resolve test_upstream,how can i resolve it? Did I do it the wrong way? this is my code:

nginx.conf

    lua_shared_dict state 10m;
    lua_shared_dict mutex 1m;
    lua_shared_dict locks 1m;
    lua_shared_dict config 10m;

    upstream charles{
        server 10.72.8.81:80 weight=2;
    }
    init_by_lua_block {
        local config = require "config"
        local checkups = require "resty.checkups.api"
        checkups.init(config)
    }

    init_worker_by_lua_block {
        local config = require "config"
        local checkups = require "resty.checkups.api"
        checkups.prepare_checker(config)
        checkups.create_checker()
    }
    server {
        location / {
            set $dynamic_proxy '';
            set_by_lua_file $test_var /opt/openresty/lua_script/dynamic_route.lua;
            proxy_pass http://$dynamic_proxy/;
        }

dynamic_route.lua

  local ngx_re = require "ngx.re"
  local uri = ngx.var.uri
  local array = ngx_re.split(uri, "/")
  local context_path = array[2]
  if "charles" == context_path then
   ngx.var.dynamic_proxy = "charles"
  end
  if "charles1" == context_path then
   ngx.var.dynamic_proxy = "test_upstream"
  end

config.lua

_M = {}
_M.global = {
    checkup_timer_interval = 15,
    checkup_shd_sync_enable = true,
    shd_config_timer_interval = 1,
}
_M.test_upstream = {
    cluster = {
        {
            servers = {
                { host = "10.72.8.81", port = 80, weight=10, max_fails=3, fail_timeout=10 },
            }
        },
    },
}
return _M

request test

http://localhost/charles
  • request
curl http://localhost/charles
  • result
<!DOCTYPE html>
<html>
<head>
<title>Welcome to OpenResty!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to OpenResty!</h1>
<p>If you see this page, the OpenResty web platform is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="https://openresty.org/">openresty.org</a>.<br/>
Commercial support is available at
<a href="https://openresty.com/">openresty.com</a>.</p>

<p><em>Thank you for flying OpenResty.</em></p>
</body>
</html>
http://localhost/charles1
  • request
curl http://localhost/charles1
  • result
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty/1.13.6.2</center>
</body>
</html>
  • error.log
2019/06/05 09:56:17 [error] 47#0: *2630 no resolver defined to resolve test_upstream, client: 172.17.0.1, server: , request: "GET /charles1 HTTP/1.1", host: "localhost"
  • it sames couldn't get dynamic upstream with lua-resty-checkups component?

round_robin轮训策略不均衡

默认是使用round_robin的,但是测试的时候发现,2台后端server,请求速率低的时候1个QPS 总是轮训到第一个,只有更高QSP的时候轮训交替正常。

创建check timer的方式为何要用lock来保证唯一性?

hello,请教下:
1 为何创建check timer要用lock的方式而不是用ngx.worker.id的方式来创建唯一timer?是有什么特殊的考虑吗?

2 在lock方式中(目前的方式),base.CHECKUP_TIMER_KEY在设置到mutex shdict中时为何要设置超时时间?(默认60s) ,

谢谢

Request distributed Uneven with consistent_hash method

I did a test found Request distributed Uneven with consistent_hash method.
upstream test have two servers:
upstream test{
server 192.168.46.111:80;
server 192.168.46.110:80;
}

hash arguments is cid.
I use 10w cid to test.
I found that the request deliver to server 192.168.46.111:80 is about 89036 .
More than eighty percent

BUT i also test original nginx with consistent method,the number of request forward to two server is equality.

DO YOU encounter the same problem? OR What is wrong with me?

os.time() 是否应该替换成 ngx.time

in base.lua

local CHECKUP_TIMER_KEY = "checkups:timer:" .. os.time()

os.time 这个函数 老生常谈了,这里是否应该使用消耗更小的 ngx.time 更为合适?

节点健康检查的状态会生效么?

hello:
读了整个代码,发现各个节点健康检查的状态只是存放到了state dict中,
除了get_status这个API将健康状况展示之外,在做流量转发的时候,并没有使用到这些状态。

是我没看到么?try_cluster选节点的时候貌似也没有涉及到健康状态。

谢谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.