You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `hash_header`: Defines the header Gorouter uses for routing decisions on this route. Required when `loadbalancing` is set to `hash`. Cannot be used with other load balancing algorithms. <%= vars.hash_routing_version %>
16
+
- `hash_balance`: Sets the float number for the balance factor used by Gorouter to manage load imbalance applying the hash-based routing for this route. Optional when `loadbalancing` is `hash`. Cannot be used with other algorithms. <%= vars.hash_routing_version %>
The per-route option `loadbalancing` allows configuring the load balancing algorithm, which defines how the load is distributed between Gorouters and backends.
21
23
22
-
This option supports two settings for load balancing:
24
+
This option supports three settings for load balancing:
23
25
24
26
- `round-robin` distributes the load evenly across all available backends
25
27
- `least-connection` directs traffic to the backend with the fewest active connections at any given time, optimizing resource utilization
28
+
- `hash` distributes requests based on a hash of a specific HTTP header, ensuring requests with the same header are consistently directed to the same backend. <%=vars.hash_routing_version%>
26
29
27
-
28
-
### <aid="lb-set-manifest"></a> Configure Load Balancing in an App Manifest
30
+
### <aid="lb-set-manifest"></a> Configure Load Balancing using an App Manifest
29
31
30
32
To configure per-route load balancing for an application that has not yet been pushed:
31
33
@@ -49,91 +51,155 @@ To configure per-route load balancing for an application that has not yet been p
49
51
cf push -f manifest.yml
50
52
```
51
53
52
-
### <aid="lb-update-route"></a> Change Load Balancing Algorithm of an Existing Route
54
+
### <aid="lb-create-route"></a> Create a Route with a Specific Load Balancing Algorithm Using the CF CLI
55
+
56
+
To create a route with a per-route `loadbalancing` option, you can use the CLI command `create-route`.
To create a route with a per-route `loadbalancing` option, you can use the cli command `create-route`.
79
-
For example:
97
+
<%=vars.hash_routing_version%>
98
+
99
+
Hash-Based Routing is a load-balancing method that routes incoming requests to application instances using a hash of a specific HTTP header value. This ensures consistent routing, so requests with the same header value always go to the same instance. The per-route hash options offer detailed control over hash-based load balancing for individual routes.
100
+
101
+
### <aid="options-hash-set-manifest"></a> Configure Hash-Based Routing with an App Manifest
102
+
1. In the application manifest, include a `route` definition with the following `options` attributes:
103
+
- `loadbalancing` set to `hash`
104
+
- `hash_header` set to the HTTP header name used for routing decisions
105
+
- optionally, `hash_balance` set to a float number for the balance factor used by Gorouter to [manage load imbalance](hash-based-routing.html#handling-imbalance-loads) for this particular route.
106
+
107
+
```yaml
108
+
---
109
+
applications:
110
+
- name: MY-APP
111
+
routes:
112
+
- route: MY-HOST.EXAMPLE.COM
113
+
options:
114
+
loadbalancing: hash
115
+
hash_header: HASH-HEADER-NAME
116
+
hash_balance: 1.2
117
+
```
118
+
119
+
Where `MY-APP` is the name of your app, `MY-HOST.EXAMPLE.COM` is the route you want to map to your app and `HASH-HEADER-NAME` is the HTTP header name.
120
+
121
+
1. Push the app with the manifest:
122
+
123
+
```console
124
+
cf push -f manifest.yml
125
+
```
126
+
127
+
### <aid="options-hash-create-route"></a> Create a Route with Hash-Based Options Using the CF CLI
128
+
129
+
To create a route with hash-specific options, you can use the CLI command `create-route`. For example:
### <aid="options-hash-update-route"></a>Update an Existing Route with Hash Options Using the CF CLI
114
156
115
-
To read route options, you can query the route using the `route` command:
157
+
You can change an existing route that uses the default load balancing algorithm to the hash load balancing algorithm.
158
+
159
+
For example, to change an app route's algorithm from default `round-robin` to `hash` and set `hash_header` to HASH-HEADER-NAME without a balance factor, you can run the `update-route` command:
The response lists the chosen `loadbalancing` algorithm option, e.g. `least-connection`:
165
+
To add a balance factor along with the previous settings, you can later run the `update-route` command, for example, with the `hash_balance` option set to `1.5`:
Where `MY-HOST` is the host attribute of the route. The response lists the chosen `loadbalancing` algorithm option as well:
177
+
Setting the balance factor to 0 indicates to Gorouter that load imbalance is accepted and all requests for a particular hash should be routed to the same instance as long as it's healthy, without redirecting to other predetermined instances.
178
+
179
+
### <aid="options-hash-revert"></a> Revert Hash Options Using the CF CLI
180
+
181
+
Running the `update-route` command with the `-r` flag for the option `loadbalancing` removes all hash options from the route, returning to the default load balancing algorithm:
0 commit comments