Load balancer
This policy balances incoming requests among backend endpoints to improve performance and reliability.
Through Load balancer policy, requests are routed based on the round-robin strategy and distributed across multiple endpoints.
The load for a service is balanced by directing requests to two or more services in a pool until the optimum level is achieved. The application routes requests to services in the pool sequentially, starting from the first and moving to the last, without considering the individual performance of the services.
After all services in the pool have received requests, the first service is chosen again, and the cycle repeats.
In IBM API Studio, this policy is identified by
the kind LoadBalancer.
Example of a Load balanced routing policy:
kind: LoadBalancer
apiVersion: apim.ibm.com/v1
metadata:
name: loadbalancer-routing
version: 1.0
namespace: dev
tags:
- routing
- route
- policy
spec:
input : request # optional
output : response # optional
roundRobinHttp:
verb: "GET"
endpoints:
- endpoint:
name: 'endpoint_1'
tlsClientProfile: tls_profile
url: ${pet_url_alias}
urlType: 'plain' # plain, variables, jsonata
version: HTTP/1.0 # HTTP/1.1, HTTP/2
timeout: 200
compressRequest: "br" # "gzip", "br", "deflate", "none"
decompressResponse: false
followRedirects: false
chunkedUpload: false
persistentConnections: true
suspendTimeout: 300
statusException:
- pattern: '200'
extensions:
webm-gateway:
apiVersion: api.ibm.com/v1
spec:
endpoints:
- name: 'endpoint_1'
connectionTimeout: 300
sslConfig:
keyStoreAlias: DEFAULT_IS_KEYSTORE
keyAlias: ssos
trustStoreAlias: DEFAULT_IS_TRUSTSTORE
serviceRegistryParameters:
- name: ""
value: ""
To invoke the Load balancer policy, you can specify the following configurations:
| Type | Description |
|---|---|
spec |
Describes the Load Balancer configuration. This section includes:
It also contains round robin routing, endpoint definitions, SSL configuration and service registry parameters. |
roundRobinHttp |
Defines round robin routing for HTTP. This section includes:
|
endpoint |
Specifies configuration details for each endpoint. Use the Add
endpoint button in the Endpoint configuration section to
configure these parameters. This section includes:
|
sslConfig |
Specifies SSL configuration for the endpoint. Use the Add endpoint
button in the Endpoint configuration section to configure these
parameters. This section includes:
|
serviceRegistryParameters |
Provides parameters used for constructing discovery service URIs. Use the Add
endpoint button in the Endpoint configuration section to
configure these parameters. This section includes:
|
statusException |
Defines status codes that are not treated as errors. Use the Add
endpoint button in the Endpoint configuration section to
configure these parameters. This section includes:
|
extensions.webm-gateway |
Provides gateway specific configuration. This section includes:
|