Concepts
Initial Setup
Peformance & Benchmark
Troubleshooting
FAQs
Glossary
This section describes how client applications connect to an Redis Replication cluster.
FPT Database Engine provides two endpoint types for Redis Replication clusters:
The Primary endpoint always points to the current Redis Primary node. This endpoint remains unchanged even when a failover occurs.
Applications can use this endpoint for standard Redis operations such as: GET, SET, DEL, EXPIRE, Pub/Sub.
Recommended use cases:
Redis Sentinel is responsible for monitoring Redis nodes, detecting failures, performing automatic failover, and providing service discovery for Redis clients. Sentinel enables applications to automatically connect to the active Redis Primary node without requiring configuration changes during failover events.
The Advanced endpoint is a Redis Sentinel endpoint used for:
Applications using Sentinel-aware Redis client libraries should connect through the Advanced endpoint instead of the Primary endpoint. When a failover occurs, Sentinel updates the new Primary node information and Sentinel-aware client libraries automatically reconnect using the updated topology.
3.1. redis-cli
redis-cli is not a Sentinel-aware client library. It can only connect to a single host and port at a time and does not support multi-Sentinel auto-discovery like application libraries. Therefore, when using redis-cli, customers should connect through the Primary endpoint.
redis-cli -h {vip} -p 6379 -a {redis_password}
|
3.2. Python (redis-py)
pip install redis
from redis.sentinel import Sentinel
sentinel = Sentinel(
[
("{ip_node1}", 26379),
("{ip_node2}", 26379),
("{ip_node3}", 26379),
],
socket_timeout=2,
)
redis_master = sentinel.master_for(
service_name="mymaster",
password="{redis_password}",
decode_responses=True,
)
redis_master.set("test", "hello")
print(redis_master.get("test"))
|
3.3. Node.js (ioredis)
npm install ioredis
const Redis = require("ioredis");
const redis = new Redis({
sentinels: [
{ host: "ip_node1", port: 26379 },
{ host: "ip_node2", port: 26379 },
{ host: "ip_node3", port: 26379 },
],
name: "mymaster",
password: "redis_password",
});
async function test() {
await redis.set("test", "hello");
const value = await redis.get("test");
console.log(value);
}
test();
|
3.3. Spring Boot
spring:
data:
redis:
password: redis_password
sentinel:
master: mymaster
nodes:
- ip_node1:26379
- ip_node2:26379
- ip_node3:26379
|
3.4. Java Spring Boot
For Java Spring Boot applications, FPT recommends using Spring Data Redis with either the Lettuce or Jedis client. The recommended configuration is to define Sentinel master-name and list of Sentinel nodes inside application.yml or application.properties.
# application.properties
spring.data.redis.password=redis_password
spring.data.redis.sentinel.master=mymaster
spring.data.redis.sentinel.nodes=ip_node1:26379,ip_node2:26379,ip_node3:26379
|
Older Spring Boot versions may use the configuration prefix spring.redis.* instead of spring.data.redis.*. Customers should verify the correct configuration format based on their Spring Boot version.
| Use case | Recommended endpoint |
|---|---|
| Standard application connectivity | Primary endpoint |
| Applications using Sentinel-aware client libraries | Advanced endpoint |
| redis-cli | Primary endpoint |