F5 – Redis Load Balancing Settings

This blog post will discuss some crucial configurations for integrating an F5 load balancer with a Redis setup using Sentinel for high availability. Redis Sentinel manages a master-slave configuration, and the F5 load balancer needs to recognize the current master node. We will focus on two key settings:

1. Configuring Monitor settings to detect the Redis Master.
2. Ensuring that all sessions to a failed node are terminated as soon as possible.

Monitor Settings:
The first crucial configuration is within the Monitor settings of your F5 load balancer. This is where you instruct the load balancer on determining which Redis node is currently acting as the master. This is done using send and receive strings.

Below is an example configuration:

Explanation:
In the Monitor settings, the send string can be set to a command like “INFO\r\n” or “ROLE\r\n“, and the receive string should be set to “role:master” to ensure that F5 recognizes the current master node. The interval and timeouts are essential to define how frequently the F5 will check the status of the Redis nodes.

Handling Failover:
Once the F5 load balancer is configured to detect the master node, the next step is to ensure that existing connections are handled properly during a failover. By default, connections might not be dropped even when there’s a failover, which could lead to issues. A setting under the pool settings controls this behavior.

By default, this mode is set to “none” However, in a high-availability environment, especially when using Redis, it’s advisable to change this setting to “reject” under “Action on Service Down.”

See the configuration below:

Explanation:
By setting the mode to “reject,” the F5 load balancer will immediately terminate both the client and server-side connections in the event of a node failure. This ensures that in the case of a failover, your applications will not experience issues due to lingering connections to the failed node.

Conclusion:
Configuring the F5 load balancer properly is vital when integrating it with a Redis setup using Sentinel for high availability. By setting up the monitor settings to detect the master node and ensuring that connections are terminated promptly during failovers, you can achieve a robust and highly responsive environment.