Sharing Routes

This section describes how to use and configure route weights, including:

Route Weight

A route's weight defines how much traffic is directed to an app that is mapped to the route. Specifically, the weight determines the proportion of traffic delivered to the app on a route, normalized to 100% across all apps sharing the same route.

When you create a route, the route is given an auto default weight of 0, which means the route will receive all remaining traffic. Route weights are resolved across all apps with the same route. See route sharing below.

You can use the route add and route map commands to set and manage a route's --weight. You can use route unmap to deactivate the route. See usage below.

Route Sharing

Route weights allow for multiple applications to share the same route. Apcera automatically balances incoming traffic across apps sharing the same route based on route weights. The typical use case is blue-green deployment.

For example, if you map a route to two jobs with weight of 0 for both routes, the traffic will be split across the two routes.

Another example, if app1 and app2 each have the same route, but app1's route has weight 30.0% and app2's route has 0.0%, then app1 will receive 30% of the traffic and app2 will receive 70%. If app1's route was then weighted to 100%, app2's route would receive 0% traffic.

The weights of all apps on a given route are normalized to total 100%. For example, if a route has associated apps with a weight of 0%, those apps receive the difference between the sum of all non-zero routes and 100%. For example, if app A and app B each have a route of "myapp.example.me" at 45%, while app C has "myapp.example.me" at 0%, app C receives 10% of the traffic.

For an example use of route sharing and weighting, see the Blue Green Deployment tutorial.

Managing Route Weights Using APC

The --weight flag can be used with the apc route commands route add and route map.

For example:

apc route add http://site.apcera.me --app mysite --weight 50
apc route add 10.0.0.1:1212 --app mydb --type tcp --port 4000 --weight 40%

To manage route weights you use the apc route map command. To set or update a route weight use the --weight <value> for the route on the app.

For example:

apc route map http://site.apcera.me --job mysite --weight 50

The apc route map command updates a route's weight:

``
apc route map myapp.example.me –app myapp –weight 50%


The `apc route unmap` command makes the route inactive.

apc route unmap myapp.example.me –app myapp
```

Managing Routes Weight Using the Web Console

The web console lets you map routes to jobs, and lets you set and update the route weights.

Default weight single route mapping:

drawing

Default weight multiple route mapping:

drawing

75/25 traffic split:

drawing

50/50 traffic split:

drawing

25/75 traffic split:

drawing

100% traffic:

drawing

Normalized traffic:

drawing