apisix健康检查

参考:https://apisix.apache.org/zh/docs/apisix/tutorials/health-check/

Health接口

自建接口:

{

  "plugins": {

    "response-rewrite": {

      "body": "ok",

      "body_base64": false,

      "headers": {},

      "status_code": 200

    }

  },

  "name": "apisix_health_check",

  "methods": ["GET" ],

  "upstream": {

    "timeout": {

      "read": 60,

      "connect": 60,

      "send": 60

    },

    "keepalive_pool": {

      "requests": 1000,

      "size": 320,

      "idle_timeout": 60

    },

    "hash_on": "vars",

    "labels": {},

    "type": "roundrobin",

    "pass_host": "pass",

    "nodes": {

      "127.0.0.1:80": 1

    },

    "scheme": "http"

  },

  "uris": [

    "/health"

  ]

}

 

 

 

 

健康探活

https://apisix.apache.org/zh/docs/apisix/tutorials/health-check/

当发向健康节点 A N 个连续探针都失败时(取决于如何配置),则该节点将被标记为不健康,不健康的节点将会被 APISIX 的负载均衡器忽略,无法收到请求;若某个不健康的节点,连续 M 个探针都成功,则该节点将被重新标记为健康,进而可以被代理。

探活:

{

    "upstream": {

         "nodes": {

            "127.0.0.1:1980": 1,

            "127.0.0.1:1970": 1

        },

        "type": "roundrobin",

        "retries": 2,

        "checks": {

            "active": {

                "timeout": 5,

                "http_path": "/health",

                "healthy": {

                    "interval": 2,

                    "successes": 1

                },

                "unhealthy": {

                    "interval": 10,

                    "http_failures": 3

                },

                "req_headers": ["User-Agent: curl/7.29.0"]

            },

            "passive": {

                "healthy": {

                    "http_statuses": [200, 201],

                    "successes": 3

                },

                "unhealthy": {

                    "http_statuses": [500],

                    "http_failures": 3,

                    "tcp_failures": 3

                }

            }

        }

    }

}

 

posted on 2025-02-28 14:25  星星眨着眼  阅读(93)  评论(0)    收藏  举报

导航