Skip to content

Add Redis Cluster / Sentinel support for high availability #6

Description

@piush365

Background

RedissonConfig currently connects to a single Redis node (useSingleServer). A single node is a single point of failure — if it goes down, the entire flash sale halts. Production deployments need either Redis Sentinel (leader election + failover) or Redis Cluster (sharding + replication).

Proposed Change

Make the connection mode configurable:

flashsale:
  redis:
    mode: single          # single | sentinel | cluster
    sentinel:
      master-name: mymaster
      nodes:
        - redis-sentinel-1:26379
        - redis-sentinel-2:26379
        - redis-sentinel-3:26379

RedissonConfig switches on flashsale.redis.mode:

return switch (properties.redis().mode()) {
    case SINGLE   -> buildSingleServer(properties);
    case SENTINEL -> buildSentinelServer(properties);
    case CLUSTER  -> buildClusterServer(properties);
};

Docker Compose

Add a 3-node Sentinel setup to docker-compose.yml under a redis-ha profile so the default single-node setup is unchanged for local dev.

Acceptance Criteria

  • FlashSaleProperties extended with a redis section
  • RedissonConfig switches connection mode based on config
  • Sentinel config tested with a Testcontainers Redis Sentinel setup
  • README updated with HA deployment notes
  • Single-node mode remains the default (no breaking change)

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructureDocker, CI/CD, database migrations, configredisRedis inventory, locking, or rate limitingreliabilityResilience, retries, circuit breakers, failure handling

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions