---
title: "Redis High Availability (Optional)"
url: "/redis-ha/"
weight: 7
---

# Redis High Availability

**Note:** This is optional for homelab setups. Single Redis instance is sufficient for most use cases.

## When You Need HA

Consider Redis HA if:
- Running production workloads
- Uptime > 99.9% required
- Can't afford to lose queued tasks
- Multiple workers across machines

## Redis Sentinel (Recommended)

### Setup

```yaml
# docker-compose.yml
version: '3.8'
services:
  redis-master:
    image: redis:7-alpine
    command: redis-server --maxmemory 2gb
    
  redis-replica:
    image: redis:7-alpine
    command: redis-server --slaveof redis-master 6379
    
  redis-sentinel-1:
    image: redis:7-alpine
    command: redis-sentinel /etc/redis/sentinel.conf
    volumes:
      - ./sentinel.conf:/etc/redis/sentinel.conf
```

**sentinel.conf:**
```conf
sentinel monitor mymaster redis-master 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000
```

### Application Configuration

```yaml
# worker-config.yaml
redis_addr: "redis-sentinel-1:26379,redis-sentinel-2:26379"
redis_master_name: "mymaster"
```

## Redis Cluster (Advanced)

For larger deployments with sharding needs.

```yaml
# Minimum 3 masters + 3 replicas
services:
  redis-1:
    image: redis:7-alpine
    command: redis-server --cluster-enabled yes
    
  redis-2:
    # ... similar config
```

## Homelab Alternative: Persistence Only

**For most homelabs, just enable persistence:**

```yaml
# docker-compose.yml
services:
  redis:
    image: redis:7-alpine
    command: redis-server --appendonly yes
    volumes:
      - redis_data:/data
      
volumes:
  redis_data:
```

This ensures tasks survive Redis restarts without full HA complexity.

---

**Recommendation:** Start simple. Add HA only if you experience actual downtime issues.
