Load Balancing¶
Overview¶
In case of high volume application traffic which must be distributed between multiple VM instances, Zadara Cloud Services supports the definition of load balancers and target groups. Load balancers distribute the load between the VM instances defined in the target group. This capability provides the following benefits when compared to working with individual VM instances:
Time required to complete a task is reduced.
Fault tolerance and high availability can be provided in case of VM instance failure.
When you create a load balancer, you define a target group of instances that will share the work of processing requests from an application. The application then directs its requests to the load balancer, and the load balancer distributes the work among the instances in the load balancer’s target group.
See the video demonstrating the basics of creating and configuring zCompute Load Balancers, Target Groups and Listeners:
Note
The load balancing capability must be globally enabled and configured by a system administrator, before load balancers can be created and used.
Load Balancer¶
Creating a Load Balancer¶
To create a load balancer:
Navigate to Home > Load Balancing > Load Balancers. The list of currently defined load balancers is displayed.
To create a new load balancer, click + Create from the top toolbar.
In the Create Load Balancer dialog which opens, enter the following:
Name: The new load balancer’s name.
Description: An optional description for the load balancer.
Type: The load balancer type determines the basis on which the load balancing is done. The following types are supported:
ALB: Application Load Balancer does distribution between targets based on HTTP/HTTPS sessions.
NLB: Network Load Balancer does distribution between targets based on TCP sessions regardless of the application layer protocol.
VPC: From the dropdown, select the VPC to be associated with the load balancer.
Subnet: From the dropdown, select an existing subnet to be associated with the load balancer, or click + to define a new subnet.
Elastic IP: From the dropdown, select an existing Elastic IP to be associated with load balancer, or click + to define a new Elastic IP.
Security Group: Determine the Security Groups that are associated with the load balancer, on the basis of the following selection:
Standard: To select Security Groups that are created and managed by the user and can be updated at any time. It’s the user responsibility to open the listeners’ ports and to restrict to specific sources if required.
From the dropdown, select existing Security Groups to be associated with load balancer, or click + to define and associate a new group.
Managed: To select Security Groups that are created and managed by the Load Balancer service. Listeners’ ports will be automatically open to any incoming source.
Note
This setting can’t be changed after the load balancer creation.
Instance Type: From the dropdown, select the instance type (CPU, RAM, boot disk size) to be associated with load balancer and to cope with the expected load.
IP Address: Optional <place holder>
High Availability: Check or uncheck the high availability option. When selected, additional load balancers will be created for standby, to automatically replace a failed load balancer.
Tags: Enter tags that can be used for ease of identifying the load balancer and as a filter in searches.
Click Finish.
Note
When you create a load balancer instance, the system creates a number of internal resources (including a VM). These are considered “protected resources.” To preserve the integrity of the load balancer instance, the system prevents you from deleting or modifying these resources.
Target Groups¶
A target group is a group of instances to which a load balancer directs application traffic. The instances in this group collectively do the processing work that the application requires.
Creating a Target Group¶
To create a target group:
Navigate to Home > Load Balancing > Target Groups.
The list of currently defined target groups is displayed.
To create a new target group, click + Create from the top toolbar.
The Create Target Group dialog will open.
In the Details tab, enter the following:
Name: The name of the new target group.
Description: Optional description of the new target group.
Protocol: Select the protocol used by the load balancer to access the target group.
HTTP: For an Application Load Balancer (ALB).
TCP: For a Network Load Balancer (NLB).
Default Port: The target group port used by the load balancer to connect to this target group.
Sticky Session - By default, a load balancer routes each request independently to the registered target group instance with the smallest load. However, you can use the sticky session feature to bind a user’s session to a specific instance. This ensures that all requests from the user during the session are sent to the same instance.
Duration - if sticky session is selected, enter session duration in seconds during which load balancer should consistently route the user’s request to the same VM instance.
Click Next.
The Health Check tab configurations are used by the load balancer to determine whether the target is healthy:
Port:
Traffic Port: The health check connection will be established on the port where the target accepts incoming traffic.
Custom: The health check connection will be established on a specified port for all targets in the group.
Enter the Custom port number.
Interval: The interval in seconds between health checks of an individual VM instance.
Minimum: 5 seconds.
Maximum: 300 seconds.
Timeout: The time in seconds beyond which no response means a failed health check. The value must be less than the interval’s maximum value.
Minimum: 2 seconds.
Maximum: 60 seconds.
Healthy Threshold: The number of consecutive successful health checks needed to transition a VM instance to the healthy state.
Minimum: 2 seconds.
Maximum: 10 seconds.
Unhealthy Threshold: The number of consecutive failed health checks needed to transition a VM instance to the failed state.
Minimum: 2 seconds.
Maximum: 10 seconds.
HTTP Health Check: For health checks using the HTTP protocol, configure the following:
Path: The ping path used by the load balancer to do a health check on VM instances in the target group.
HTTP Code(s): The HTTP health check response codes that determine a successful health check, and therefore a healthy target.
The following formats are supported:
A single HTTP success code, for example, 200.
Multiple HTTP success codes separated by commas, for example 200,301.
A range of HTTP success codes, specified with “-” between the first and last code in the range, for example, 200-399.
Click Next.
In the Targets tab, add targets to the group.
Target Type: Select the Target Type, click Add, and enter the target’s parameters.
Note
All targets in a Target Group must be of the same Target Type.
The following Target Types are supported:
Instance:
Enter the Instance type target’s parameters:
Select Target VM: From the dropdown, select a target VM instance.
Port: Specify the port number on the target for communication with the load balancer.
IP:
Enter the IP type target’s parameters:
IP: Enter the target’s IP address, that is both in your region and is reachable from the load balancer.
Port: Specify the port number on the target for communication with the load balancer.
To configure additional targets in the Target Group click Add, and enter the target’s parameters according to the Target Type.
Click Finish.
Listeners¶
A listener is a process that monitors a specified port for incoming connection requests. The listener’s rules determine how the load balancer routes these requests to the targets.
Every load balancer requires at least one listener, each of which must have one or more rules.
A listener’s rule consists of a condition and a resulting action. When the condition is met, the load balancer executes the corresponding action for that rule.
When multiple rules are configured for a listener, they are evaluated sequentially based on their order. If the condition of the first rule is not met, the subsequent rules are assessed in turn. When a rule’s condition is met and its corresponding action executed, no further subsequent rule is assessed for the incoming connection request. The final rule in the sequence includes a default condition indicating that none of the preceding rules matched the incoming request, and the load balancer will execute its corresponding action.
The order of all the rules except for the final one can be changed by dragging and dropping a rule into its preferred position in the sequence.
Creating a Listener¶
There are some differences in listener configuration options, depending on the type of load balancer:
Creating a Listener for NLB type Load Balancer¶
Navigate to Home > Load Balancing > Target Groups.
The list of currently defined target groups is displayed.
Select the NLB type load balancer for which the listener is being created.
In the load balancer’s lower pane’s Listeners tab, click + Create.
In the Create Listener dialog:
Protocol: The Protocol is set to TCP and cannot be modified.
Port: Enter the listener’s port.
Rule:
Note
It is not possible to create multiple rules for an NLB type load balancer’s listener. Only the default rule is applicable and required. As a sole required rule, there is no condition for assessment.
The resulting Action is to Forward the incoming requests to a selected Target Group.
Action: The rule’s Action is to Forward the incoming requests to the Target Group specified in Forward to below. The Action cannot be modified for an NLB type load balancer’s rule.
Forward to: Select the destination Target Group from the dropdown, or click + to create a new one.
Click Finish.
Creating a Listener for ALB type Load Balancer¶
Navigate to Home > Load Balancing > Target Groups.
The list of currently defined target groups is displayed.
Select the ALB type load balancer for which the listener is being created.
In the load balancer’s lower pane’s Listeners tab, click + Create.
In the Create Listener dialog:
Protocol: Select HTTP or HTTPS.
For HTTPS, select or upload a Default SSL Certificate.
Port: Enter the listener’s port.
Rules
Define the listener’s rules, starting with the default rule’s action:
To create additional rules, click +Add Rule.
Click + Add Condition, select one of the conditions from the dropdown and enter its parameter values:
Condition
Parameter values
Header
Header name and value patterns
Path
Path patterns
Host
Host names
Method
One or more of the HTTP methods:
GET
HEAD
POST
PUT
PATCH
DELETE
OPTIONS
IP
The CIDR blocks that contain the source IP addresses.
Click Add CIDR to add another CIDR block.
Click + Add Condition to add another condition to the same rule.
Note
Multiple conditions can be configured in a single rule for a listener of an ALB type load balancer.
Action: Configure the rule’s action, corresponding to the condition.
Select the applicable action, and enter its parameter values:
Action
Parameter values
Forward
Forward to: Select the destination target group
Fixed Response
Status Code The HTTP status code value
Send Content (optional).
If selected, for Content Type select one of:
text/plain
text/css
text/html
application/javascript
application/json
Response body: Upload the response body file,
up to a maximum size of 1 KB
Redirect
Protocol: Leave it Unchanged, or select HTTP or HTTPS
Port: Enter the target port number, or select Unchanged
to default to the target’s original configured port
Path: The redirect URL that must be sent to the client’s browser
Query: The query portion of the redirect URL
Status Code:
301 (Moved Permanently)
302 (Moved Temporarily)
To create an additional rule, click +Add Rule.
Click Finish.