Open Closed

Support for Redis Multi-Node Setup in Kubernetes #8901


User avatar
0
pooria.shariatzadeh@gmail.com created
  • ABP Framework version: v8.3.2

  • Tiered: yes

Hello Support Team,

We are deploying our application in a Kubernetes environment with a multi-pod, multi-zone architecture and are using Redis for distributed caching and event bus communication.

We would like to confirm whether the system fully supports Redis Cluster Mode with multiple nodes and ensure the correct configuration.

Questions:
Does the system natively support Redis Cluster Mode for distributed caching and event bus communication?
Is any custom logic required for handling multiple Redis nodes?
How does the system handle failover in case one of the Redis nodes becomes unavailable?
Could you provide a sample configuration for integrating Redis in a multi-node Kubernetes environment?
We appreciate your guidance and look forward to your response.

Best regards,
Pooria Sahriatzadeh


1 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, here are the answers for your questions:

    1-) Does the system natively support Redis Cluster Mode for distributed caching and event bus communication?

    ABP's redis package (Volo.Abp.Caching.StackExchangeRedis) uses the Microsoft.Extensions.Caching.StackExchangeRedis package and it should support Redis Cluster as long as the proper connection string is provided for distributed caching.

    For our event bus providers please see https://abp.io/docs/latest/framework/infrastructure/event-bus/distributed#providers

    2-) Is any custom logic required for handling multiple Redis nodes?

    If you're using a single Redis instance or Sentinel Mode, no custom logic is required as far as I know. However, if you're using Redis Cluster Mode, you should:

    • Ensure that the connection string includes all cluster nodes.

    • Set abortConnect=false to allow automatic failover handling.

    • Consider using a cluster-aware Redis library if advanced failover handling is needed.

    3-) How does the system handle failover in case one of the Redis nodes becomes unavailable?

    StackExchange.Redis will attempt to reconnect to available nodes automatically, but it does not natively support Redis Cluster failover in an optimal way.

    If you're running in Redis Cluster Mode, you need to handle reconnections properly in your configuration to avoid interruptions in caching or event handling.

    4-) Could you provide a sample configuration for integrating Redis in a multi-node Kubernetes environment?

    Since this is not fully related to ABP, rather than it's related to Redis configuration, I don't have a sample configuration for that.

    But, in your appsettings.json, a configuration like below should work:

    "Redis": {
      "Configuration": "node1:6379,node2:6379,node3:6379,abortConnect=false"
    }
    

    Set abortConnect=false to allow automatic failover handling.

    or you can configure RedisCacheOption in your module as below:

            Configure<RedisCacheOptions>(options =>
            {
                options.ConfigurationOptions = new ConfigurationOptions
                {
                    EndPoints = { "node1:6379", "node2:6379", "node3:6379" },
                    AbortOnConnectFail = false,
                    ConnectRetry = 5
                };
            });
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08