-
-
Notifications
You must be signed in to change notification settings - Fork 947
Automatic Failover
Ken Hibino edited this page Jan 20, 2020
·
8 revisions
This page explains how to configure asynq to take advantage of Redis Sentinel to avoid downtime due to Redis failure.
Please read the doc on Redis Sentinel to understand the topic.
Configuring asynq's Client and Background to use Redis Sentinel is simple.
Use RedisFailoverClientOpt to speicfy the name of your Redis master and addresses of your Redis Sentinels.
var redis = &asynq.RedisFailoverClientOpt{
MasterName: "mymaster",
SentinelAddrs: []string{"localhost:5000", "localhost:5001", "localhost:5002"},
}And pass this client option to NewClient and NewBackground to create an instance that uses Redis Sentinels.
client := asynq.NewClient(redis)
// ...
bg := asynq.NewBackground(redis, &asynq.Config{ Concurrency: 10 })With this setup, if you Redis master goes down Redis Sentinel will start a failover process and asynq will be notified of new master and you background task processing will continue to work 👍.