cloudfoundry / gorouter

CF Router
Apache License 2.0
441 stars 226 forks source link

Generic Per-Route Options incl. Load Balancing Algorithm #428

Closed Dariquest closed 3 months ago

Dariquest commented 4 months ago

Summary

Detailed specification including that of for all the involved components is provided in the RFC

Route definition is extended by generic options map with a load balancing algorithm. Options can be optionally specified in the following way with a json key lb_algo for the load balancing algorithm, e.g.

{
  "host": "127.0.0.1",
  "port": 4567,
  "protocol": "http1",
  "uris": ["url.localhost.routing.cf-app.com"],
  "options": {
    "lb_algo": "least-connection"
  },
  "app": "some_app_guid",
  "stale_threshold_in_seconds": 120,
  "server_cert_domain_san": "some_subject_alternative_name"
}

Supported load-balancing algorithms are specified in the Gorouter configuration in the LoadBalancingStrategies list. If a load balancing algorithm, provided for a route, is not in this configured list, the pool load balancing algorithm is kept and the error invalid-endpoint-load-balancing-algorithm-provided-keeping-pool-lb-algo is logged.

RegistryMessage structure is extended by an Options field of type RegistryMessageOpts structure, currently only containing the LoadBalancingAlgorithm field. Endpoint structure is extended by LoadBalancingAlgorithm field.

When initialising new endpoints, the load balancing algorithm is initialised to the value from the corresponding registry message option. When endpoints are registered and added to the pool, the load balancing algorithm of a pool is set to that one of a new endpoint.

RouteRegistry structure is extended by a new field DefaultLoadBalancingAlgorithm, which is initialised by the Gorouter default load balancing configuration property LoadBalance. This default value is a default load balancing algorithm for a new pool.

Since the route options are optional, not providing them has no effect on the existing default load balancing algorithm logic.

Backward Compatibility

Breaking Change? No

Check list

Resolves: cloudfoundry/routing-release#421

linux-foundation-easycla[bot] commented 4 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

Dariquest commented 3 months ago

Corresponding issue https://github.com/cloudfoundry/routing-release/issues/421

Dariquest commented 3 months ago

Found a small typo, looks good overall.

@stefanlay Thanks!