> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Redis configuration

> Configure Redis deployment modes for FlowX platform services

## Overview

FlowX platform services use Redis for caching and real-time data management. Redis can be deployed in three different modes depending on your availability and scalability requirements.

All FlowX Java microservices support the same Redis configuration properties based on Spring Boot's Redis data configuration.

## Supported deployment modes

FlowX supports three Redis deployment modes:

* **Standalone**: Single Redis instance (suitable for development and low-traffic environments)
* **Sentinel**: High availability with automatic failover (recommended for production)
* **Cluster**: Horizontal scaling with data sharding (for high-throughput applications)

<Warning>
  Master-Replica mode is not supported. Use Sentinel mode for high availability with automatic failover, or Cluster mode for horizontal scaling.
</Warning>

## Standalone mode

The default configuration for single Redis instance deployments.

### Configuration parameters

| Environment Variable            | Description                       | Example Value                      | Required                     |
| ------------------------------- | --------------------------------- | ---------------------------------- | ---------------------------- |
| `SPRING_DATA_REDIS_HOST`        | Hostname of the Redis server      | `localhost` or `redis.example.com` | Yes                          |
| `SPRING_DATA_REDIS_PORT`        | Port number for Redis server      | `6379` (default)                   | Yes                          |
| `SPRING_DATA_REDIS_PASSWORD`    | Password for Redis authentication | `yourpassword`                     | If authentication is enabled |
| `SPRING_DATA_REDIS_SSL_ENABLED` | Enable SSL/TLS connection         | `true` or `false`                  | No                           |

### Example configuration

```yaml theme={"system"}
spring:
  data:
    redis:
      host: localhost
      port: 6379
      password: yourpassword
      ssl:
        enabled: false
```

## Sentinel mode

For high-availability Redis with automatic failover. Sentinel provides monitoring, notification, and automatic failover capabilities.

### Configuration parameters

| Environment Variable                  | Description                                               | Example Value                         | Required                              |
| ------------------------------------- | --------------------------------------------------------- | ------------------------------------- | ------------------------------------- |
| `SPRING_DATA_REDIS_SENTINEL_MASTER`   | Name of the Redis master instance                         | `mymaster`                            | Yes                                   |
| `SPRING_DATA_REDIS_SENTINEL_NODES`    | Comma-separated list of Sentinel nodes (host:port format) | `host1:26379,host2:26379,host3:26379` | Yes                                   |
| `SPRING_DATA_REDIS_SENTINEL_PASSWORD` | Password for Sentinel authentication                      | `sentinelpassword`                    | If Sentinel authentication is enabled |
| `SPRING_DATA_REDIS_PASSWORD`          | Password for Redis data node authentication               | `yourpassword`                        | If Redis authentication is enabled    |

### Example configuration

```yaml theme={"system"}
spring:
  data:
    redis:
      sentinel:
        master: mymaster
        nodes: sentinel1:26379,sentinel2:26379,sentinel3:26379
        password: sentinelpassword
      password: yourpassword
```

### Important notes

<Info>
  * The `SPRING_DATA_REDIS_SENTINEL_NODES` must include all Sentinel instances for redundancy
  * Sentinel typically runs on port `26379` (different from Redis data port `6379`)
  * The master name (`SPRING_DATA_REDIS_SENTINEL_MASTER`) must match the master configured in your Sentinel setup
  * Both Sentinel password and Redis password can be configured independently
</Info>

## Cluster mode

For Redis cluster deployments with data sharding across multiple nodes, providing horizontal scalability.

### Configuration parameters

| Environment Variable              | Description                                              | Example Value                      | Required                     |
| --------------------------------- | -------------------------------------------------------- | ---------------------------------- | ---------------------------- |
| `SPRING_DATA_REDIS_CLUSTER_NODES` | Comma-separated list of cluster nodes (host:port format) | `host1:6379,host2:6379,host3:6379` | Yes                          |
| `SPRING_DATA_REDIS_PASSWORD`      | Password for Redis cluster authentication                | `yourpassword`                     | If authentication is enabled |

### Example configuration

```yaml theme={"system"}
spring:
  data:
    redis:
      cluster:
        nodes: node1:6379,node2:6379,node3:6379
      password: yourpassword
```

### Important notes

<Info>
  * You only need to specify a subset of cluster nodes; the Redis client will discover all nodes automatically
  * At least 3 master nodes are recommended for a production Redis cluster
  * Data is automatically sharded across cluster nodes
</Info>

## Choosing the right deployment mode

Use this guide to select the appropriate Redis deployment mode:

<Tabs>
  <Tab title="Development & Testing">
    **Standalone mode** is suitable for:

    * Development environments
    * Testing and staging environments
    * Low-traffic applications
    * Single-server deployments

    **Considerations:**

    * No automatic failover
    * Single point of failure
    * Simplest to set up and maintain
  </Tab>

  <Tab title="Production - High Availability">
    **Sentinel mode** is recommended for:

    * Production environments requiring high availability
    * Applications that need automatic failover
    * Deployments where downtime is not acceptable
    * Single-master write scenarios

    **Considerations:**

    * Automatic failover to replica nodes
    * Monitoring and notifications
    * More complex setup than standalone
    * No data sharding (vertical scaling)
  </Tab>

  <Tab title="Production - High Throughput">
    **Cluster mode** is ideal for:

    * High-throughput applications
    * Large datasets requiring data sharding
    * Horizontal scaling requirements
    * Multi-master write scenarios

    **Considerations:**

    * Data automatically distributed across nodes
    * Horizontal scalability
    * Most complex to set up and maintain
    * Different behavior than single-instance Redis (some commands not supported)
  </Tab>
</Tabs>

## SSL/TLS configuration

For secure Redis connections, you can enable SSL/TLS:

| Environment Variable            | Description                          | Example Value |
| ------------------------------- | ------------------------------------ | ------------- |
| `SPRING_DATA_REDIS_SSL_ENABLED` | Enable SSL/TLS for Redis connections | `true`        |

```yaml theme={"system"}
spring:
  data:
    redis:
      ssl:
        enabled: true
```

<Info>
  SSL/TLS configuration is supported in all deployment modes (Standalone, Sentinel, and Cluster).
</Info>

## Additional configuration options

### Connection timeout

| Environment Variable        | Description                        | Default Value |
| --------------------------- | ---------------------------------- | ------------- |
| `SPRING_DATA_REDIS_TIMEOUT` | Connection timeout in milliseconds | `2000`        |

### TTL (Time To Live)

Some services support custom TTL configuration for cached data:

| Environment Variable | Description                                     | Default Value    |
| -------------------- | ----------------------------------------------- | ---------------- |
| `REDIS_TTL`          | Time to live for cached entries in milliseconds | Service-specific |

<Info>
  Check individual service setup guides for service-specific Redis configuration options.
</Info>

## Applying configuration

<Steps>
  <Step title="Choose your deployment mode">
    Select the appropriate Redis deployment mode based on your requirements (Standalone, Sentinel, or Cluster).
  </Step>

  <Step title="Set environment variables">
    Configure the required environment variables for your chosen deployment mode in your deployment configuration (Kubernetes ConfigMap, Docker Compose, etc.).
  </Step>

  <Step title="Verify Redis connectivity">
    Ensure your FlowX services can reach the Redis instance(s) on the network level.
  </Step>

  <Step title="Test the configuration">
    Deploy your services and verify Redis connectivity through service logs and health checks.
  </Step>
</Steps>

## Services using Redis

The following FlowX services use Redis and support these configuration options:

* Events Gateway
* Authorization System
* FlowX Engine
* Notification Plugin
* Document Plugin
* OCR Plugin
* Task Management Plugin

<Info>
  For service-specific Redis configuration details, refer to the individual setup guides in the [Setup Guides section](/5.9/setup-guides/setup-guides-overview).
</Info>

## Troubleshooting

### Connection issues

If services cannot connect to Redis:

1. **Verify network connectivity**: Ensure the service can reach Redis hosts on the configured ports
2. **Check authentication**: Verify the password is correct
3. **Review firewall rules**: Ensure no firewall is blocking Redis ports
4. **Validate configuration**: Double-check environment variable names and values

### Sentinel mode issues

If Sentinel failover is not working:

1. **Verify master name**: Ensure `SPRING_DATA_REDIS_SENTINEL_MASTER` matches your Sentinel configuration
2. **Check all Sentinel nodes**: All Sentinel instances should be reachable
3. **Review Sentinel logs**: Check Sentinel logs for failover events
4. **Validate Sentinel password**: If using Sentinel authentication, ensure `SPRING_DATA_REDIS_SENTINEL_PASSWORD` is correct

### Cluster mode issues

If cluster operations fail:

1. **Verify cluster health**: Check Redis cluster status with `CLUSTER INFO`
2. **Ensure minimum nodes**: At least 3 master nodes should be running
3. **Check node discovery**: Ensure the service can discover all cluster nodes
4. **Review unsupported commands**: Some Redis commands are not supported in cluster mode

## Related documentation

<CardGroup>
  <Card title="Kafka Authentication" icon="lock" href="/5.9/setup-guides/kafka-authentication-config">
    Configure secure Kafka communication
  </Card>

  <Card title="Events Gateway Setup" icon="tower-broadcast" href="/5.9/setup-guides/events-gateway-setup">
    Complete Events Gateway configuration
  </Card>

  <Card title="Setup Guides Overview" icon="book" href="/5.9/setup-guides/setup-guides-overview">
    View all setup guides
  </Card>
</CardGroup>
