Load Balancing
A load balancing group is a group of Key Manager servers the client can connect to. Load balancing is a mechanism to equally distribute the connection load across the Key Managers when there are concurrent requests. To add multiple key managers, refer to Add Multiple Key Managers.
CADP for Java also allows you to create multiple levels of load balancing groups., called as tiers. For details, refer to Multi-Tier Load Balancing
How it works
The following steps describe what happens when the client attempts to connect to the load balancing group for the first time:
The client creates a session. This in turn creates a new load balancer. The load balancer stores the
NAE_IP
,NAE_Port
,KMIP_Port
,Protocol
,Connection_Timeout
,Connection_Retry_Interval
, and Unreachable_Server_Retry_Period` parameters.If persistent connections are enabled, the load balancer also creates a new connection pool for each server in the load balancing group. else, the connection pool is not created.
Tip
It is recommended to enable persistent connection.
The client requests a connection from the load balancer. For the first connection request, the load balancer chooses one of the available Key Managers at random and creates a connection. For future requests, the load balancer will apply the
Load_Balancing_Algorithm
to decide which Key Manager to use.The client waits the duration of
Connection_Timeout
for a server response.If server 1 does not respond within the timeout period. The client ignores server 1 for the duration of the
Connection_Retry_Interval
.The client attempts to connect to server 2.
The client obtains the connection.
The client uses the connection to send a cryptographic request to server 2.
Server 2 sends the response.
The load balancer keeps the connection in the connection pool, if persistent connections are enabled. Otherwise, the connection is closed.
Related parameters
NAE_IP
NAE_Port
KMIP_Port
Protocol
Load_Balancing_Algorithm
Connection_Timeout
Connection_Retry_Interval
Unreachable_Server_Retry_Period
For more information about these parameters, refer to Connection Parameters.
Examples
The defaults
The CADP_for_JAVA.properties uses the following default values:
Connection_Timeout=1m
Connection_Read_Timeout=7000
Connection_Retry_Interval=600000
Unreachable_Server_Retry_Period=60000
Maximum_Server_Retry_Period=0
Let's understand the impact of these parameters on load balancing:
Parameter | Impact on Load balancing |
---|---|
Connection_Timeout | The client gets an error if it takes longer than 1 minute to get a response from a server. |
Connection_Read_Timeout | Once a connection is made, the client gets an error if it takes longer than 7 seconds for a server to send data. |
Connection_Retry_Interval | If the client can’t connect to a server within the Connection_Timeout , or can’t read data within the Connection_Read_Timeout , the client will take that server out of the round-robin rotation for 10 minutes (600000 milliseconds). |
Unreachable_Server_Retry | If the client can’t connect to any server in the load balancing group within 1 minute, it will attempt to connect to the next load balancing group or it will send an error message if no other load balancing group exists. |
Maximum_Server_Retry_Period | It is disabled by default. |
Setting Unreachable_Server_Retry_Period
We’ll still use NAE_IP.1
=alpha:beta:gamma, but for this example, we’ll configure new values for Connection_Timeout
and Unreachable_Server_Retry_Period
parameters. The values of Connection_Read_Timeout
, Connection_Retry_Interval
, and Maximum_Server_Retry
are unchanged (default).
Connection_Timeout=2000
Connection_Read_Timeout=7000
Connection_Retry_Interval=600000
Unreachable_Server_Retry_Period=840000
Maximum_Server_Retry_Period=0
The following table highlights the impact of these parameters on load balancing:
Parameter | Impact on Load balancing |
---|---|
Connection_Timeout | The client gets an error if it takes more than 2 seconds to get a response from a server. In the event that the server (or your network) is under a heavy load, you could get a timeout even for a running server. In this case, if you set Connection_Retry_Interval too low, you’ll just end up bombarding an already overloaded server. |
Unreachable_Server_Retry_Period | The client gets an error if it takes more than 14 minutes to get a connection from one of the servers in the load balancing group. 14 minutes gives enough time for the Connection_Retry_Interval to expire. |
Setting Maximum_Server_Retry_Period
Now we’ll set Unreachable_Server_Retry_Period
to the infinite retry period. We’ll counter this by setting Maximum_Server_Retry_Period
.
Connection_Timeout=2000
Connection_Read_Timeout=7000
Connection_Retry_Interval=600000
Unreachable_Server_Retry_Period=-1
Maximum_Server_Retry_Period=1200000
The following table highlights the impact of these parameters on load balancing:
Parameter | Impact on Load balancing |
---|---|
Unreachable_Server_Retry | Even if all of the servers are taken out of the round-robin rotation, the client won’t consider the load balancing group unavailable. It will wait 10 minutes and retry the first server that was taken out of rotation. |
Maximum_Server_Retry_Period | The client gets an error if it takes more than 20 minutes to get a connection to a server. 20 minutes gives enough time for the Connection_Retry_Interval to expire twice. |