Failover API handling

This was the solution that worked for me, with a similar requirement for primary and backup service.

the suggested design will only send 1/1000 request to backup server instead of primary, which resonable in my case.

Another useful article was, Upstreams and failover - #9 by scortopassi

Here are my configurations,

_format_version: '1.1'

services:
- name: my-service
  host: my-upstream
  port: 8000
  protocol: http
  retries: 3
  routes:
  - name: my-route
    paths:
    - /

upstreams:
- name: my-upstream
  targets:
  - target: 192.168.3.23:10102
    weight: 1000
  - target: 192.168.3.28:10102
    weight: 1
  healthchecks:
    active:
      concurrency: 2
      healthy:
        http_statuses:
        - 200
        - 302
        interval: 0
        successes: 1
      http_path: /testKong
      timeout: 1
      type: http
      unhealthy:
        http_failures: 3
        http_statuses:
        - 429
        - 404
        - 500
        - 501
        - 502
        - 503
        - 504
        - 505
        interval: 1
        tcp_failures: 3
        timeouts: 3
    passive:
      healthy:
        http_statuses:
        - 200
        - 201
        - 202
        - 203
        - 204
        - 205
        - 206
        - 207
        - 208
        - 226
        - 300
        - 301
        - 302
        - 303
        - 304
        - 305
        - 306
        - 307
        - 308
        successes: 1
      type: http
      unhealthy:
        http_failures: 1
        http_statuses:
        - 429
        - 500
        - 503
        tcp_failures: 1
        timeouts: 1
  slots: 1000
1 Like