Set Up Intelligent Load Balancing
In this topic, you’ll learn about configuring upstream services, and create multiple targets for load balancing.
If you are following the getting started workflow, make sure you have completed Secure Services Using Authentication before moving on.
What are Upstreams?
An Upstream Object refers to your upstream API/service sitting behind Kong Gateway, to which client requests are forwarded. In Kong Gateway, an Upstream Object represents a virtual hostname and can be used to health check, circuit break, and load balance incoming requests over multiple services (targets).
In this topic, you’ll configure the service created earlier (
example_service) to point to an upstream instead of the host. For the purposes of our example, the upstream will point to two different targets,
mockbin.org. In a real environment, the upstream will point to the same service running on multiple systems.
Here is a diagram illustrating the setup:
Why load balance across upstream targets?
In the following example, you’ll use an application deployed across two different servers, or upstream targets. Kong Gateway needs to load balance across both servers, so that if one of the servers is unavailable, it automatically detects the problem and routes all traffic to the working server.
Configure Upstream Services
In this section, you will create an Upstream named
upstream and add two targets to it.
You now have an Upstream with two targets,
mockbin.org, and a service pointing to that Upstream.
Validate the Upstream Services
- With the Upstream configured, validate that it’s working by visiting the route
http://<admin-hostname>:8000/mock using a web browser or CLI.
- Continue hitting the endpoint and the site should change from
Summary and next steps
In this topic, you:
- Created an Upstream object named
upstream and pointed the Service
example_service to it.
- Added two targets,
mockbin.org, with equal weight to the Upstream.
If you have a Kong Konnect subscription, go on to Managing Administrative Teams.