A Target identifies an instance of an upstream service using an IP address or hostname with a port.
Each Upstream can have many Targets. Targets are used by Upstreams for load balancing. For example, if you have an example_upstream
Upstream, you can point it to two different Targets: httpbin.konghq.com
and httpbun.com
. This is so that if one of the servers (like httpbin.konghq.com
) is unavailable, it automatically detects the problem and routes all traffic to the working server (httpbun.com
).
The following diagram illustrates how Targets are used by Upstreams for load balancing:
flowchart LR A("Request") B("`Route (/mock)`") C("`Service (example_service)`") D("Target: httpbin.konghq.com") E("Target: httpbun.com") F(Upstream service: httpbin.konghq.com) G(Upstream service: httpbun.com) A --> B subgraph id1 ["`**KONG GATEWAY**`"] B --> C --> D & E subgraph id3 ["`**Upstream** (load balancer)`"] D & E end end subgraph id2 ["`**Target upstream services**`"] D --> F E --> G end style id2 stroke:none!important