Sometimes you might want to split the incoming traffic to a service between its different versions and/or external services. The various use cases for traffic splitting include but are not limited to:
To configure the splitting of service traffic, we need to set up some rules in the Rules
tab of the Deployments
section:
To add a routing rule for a service, click on the Add
button besides its routing rules to open a form like this:
Each incoming request to an internal service is routed to one of the specified targets. A target can be a version of that service or an external host and is selected randomly based on the weight assigned to it.
As of now, you can split incoming to an external service on the basis of port only.
Targets:
Target type | Version | Port | Weight |
---|---|---|---|
Internal service version |
v1 |
8080 |
80 |
Internal service version |
v2 |
8080 |
20 |
The above config splits the incoming traffic to a service between its 2 versions (v1
and v2
). The splitting of traffic is random based on the weights. This means that roughly 80% of requests will go to v1
while 20% will go to v2
.
Targets:
Target type | Version/Host | Port | Weight |
---|---|---|---|
Internal service version |
Verson - v1 |
8080 |
50 |
Internal service version |
Verson - v2 |
8081 |
30 |
External host |
Host - example.com |
5000 |
20 |
The above config helps us to route 50% of incoming service requests to its v1
version and 30% to its v2
version. While the rest 20% goes to an external host example.com
.