Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request help: Health Checks can support Backup server? #1809

Closed
souzens opened this issue Jul 7, 2020 · 4 comments · Fixed by #3755
Closed

request help: Health Checks can support Backup server? #1809

souzens opened this issue Jul 7, 2020 · 4 comments · Fixed by #3755

Comments

@souzens
Copy link

souzens commented Jul 7, 2020

Issue description

health Check plugin in base on Kong lua-resty-healthcheck.

I need a function that can mark an upstream server as backup.
It will be passed requests when only the primary servers are unavailable.

##LIKE NGINX UPSTREAM CONFIG

upstream  testproxy  {
        server   192.168.1.14:8080;
        server   192.168.1.200:8080 backup;
}

USE nginx upstream on http://nginx.org/en/docs/http/ngx_http_upstream_module.html

Environment

  • apisix version (cmd: apisix version): 1.4
  • OS: centos7
@membphis
Copy link
Member

membphis commented Jul 7, 2020

I know this is a bit complicated, I will try to see if there is a simpler way later.

127.0.0.1:9999 is an invalid upstream.
It'll choose 127.0.0.1:1980 when the 127.0.0.1:9999 turn to unhealthy.

curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/index.html",
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "127.0.0.1:9999": 1,
            "127.0.0.1:1980": 0
        },
        "checks": {
            "active": {
                "http_path": "/status",
                "host": "test",
                "healthy": {
                    "interval": 2,
                    "successes": 1
                },
                "unhealthy": {
                    "interval": 1,
                    "http_failures": 2
                }
            },
            "passive": {
                "healthy": {
                    "http_statuses": [200, 201],
                    "successes": 3
                },
                "unhealthy": {
                    "http_statuses": [500, 502],
                    "http_failures": 3,
                    "tcp_failures": 3
                }
            }
        }
    }
}'

@souzens
Copy link
Author

souzens commented Jul 7, 2020

and another request:

sometimes http work and health check listen on different ports ,

like spring boot cloud
http api request works on 8080,
but actuator health works on 8888 port

so a router config like :

            "active": {
                "http_path": "/actuator/health",
                "port": "8888",
                "host": "test",
                "healthy": {
                    "interval": 2,
                    "successes": 1
                },
                "unhealthy": {
                    "interval": 1,
                    "http_failures": 2
                }
            },
            "passive": {
                "healthy": {
                    "http_statuses": [200],
                    "successes": 3
                },
                "unhealthy": {
                    "http_statuses": [503,404],
                    "http_failures": 3,
                    "tcp_failures": 3
                }
            }

i did not find any health port define in https://github.com/apache/incubator-apisix/blob/master/apisix/schema_def.lua#L81

is it supported now ?

@membphis
Copy link
Member

membphis commented Jul 7, 2020

@souzens #1809 (comment)

you should create a new issue about this new question. they were two different things.

@spacewander
Copy link
Member

The zero weight node trick works well with most occasions, but it doesn't with chash or least conn balancer.

@spacewander spacewander added bug Something isn't working and removed bug Something isn't working labels Jan 20, 2021
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Mar 4, 2021
spacewander added a commit to spacewander/incubator-apisix that referenced this issue Mar 4, 2021
spacewander added a commit that referenced this issue Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants