Meta description: Spread traffic across several backend instances and automatically stop sending requests to failing ones.
What you'll learn
Upstreams and Targets
Kong's load balancing algorithms
Active and passive health checks
How to test failover yourself
Why one backend isn't enough
A single instance of your API is a single point of failure, and it can only handle so much load. In practice you run several copies . Kong needs to know:
How to distribute requests across them (load balancing)
How to avoid the broken ones (health checks)
The concepts
Upstream: a virtual name that stands for a pool of backends.
Target: one real instance in the pool ( host:port ), with a weight .
ββ Target 1: alpha1:8080 Kong β Upstream "alpha-upstream" β€ ββ Target 2: alpha2:8080
Enter fullscreen mode
Exit fullscreen mode
Setting it up
1. Create the upstream
curl -i -X POST http://localhost:8001/upstreams --data name = alpha-upstream
Enter fullscreen mode
Exit fullscreen mode
2.β¦