Redis cluster - access via load balancer

46 views
Skip to first unread message

Walter Heestermans

unread,
Apr 23, 2018, 8:41:51 AM4/23/18
to Redis DB
Hi,

When I have a cluster with three masters and three slaves. Each server will have a slot range assigned.

When applications try to get access to the cluster, does the application need to make connection connection to one of the masters and the correct one will then be routed? Application can connect to any master and will work fine?

Is it better to put a load balancer in front of our redis masters to get access?

What is the preferred setup?


ma...@andyh.io

unread,
Apr 23, 2018, 10:18:00 AM4/23/18
to redi...@googlegroups.com
Hi

The load balancer has to know the route to the slots. Therefore setting up a dummy LB does not make too much sense.

For other reasons, you might want to setup a balancer(proxy) between applications and the cluster. That proxy needs to understand Redis Cluster protocol. For example, when you have applications written in different languages and you want to guarantee the the behaviours across them.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

hva...@gmail.com

unread,
Apr 23, 2018, 2:36:16 PM4/23/18
to Redis DB

You asked:

Each server will have a slot range assigned.
When applications try to get access to the cluster, does the application need to make connection connection to one of the masters and the correct one will then be routed? Application can connect to any master and will work fine?

The answer is "No".  Whether you're using the sharded configuration (known as Redis Cluster) or the non-sharded configuration, the Redis server your client connects to will not proxy the connection to the servers that possess the key/slot.
  • The sharded configuration will return a response to the client that says "I don't have the key/slot you're trying to access, you must connect to [this other server] instead."  (see the "MOVED" response example at https://redis.io/topics/cluster-spec#redirection-and-resharding).  The client must understand the reply and connect to the appropriate server.
  • The non-sharded configuration will return an error saying the key/slot doesn't exist.  If you're using the non-sharded configuration, the allocation of slots is done in the clients (or in a proxy between the clients and servers), so the Redis servers don't know about the other Redis servers and can't suggest the correct one.  The client (or proxy) must connect to the appropriate server.
If you have a load balancer or proxy that understands the Redis client/server protocol enough to manage the connection decisions, then it makes sense to use one.  If you don't, then your balancer/proxy will cause problems by connecting to the wrong Redis server for the key/slot.

William Davis

unread,
Apr 24, 2018, 1:51:15 PM4/24/18
to Redis DB
Redis cluster, with slaves, provides you with both sharding and failover. If you want HA connections, use DNS entries. Clients such as StackExchange.Redis (for .net) will automatically enumerate all redis servers in the cluster and provide connections to each as required once you connect to a single instance.
Reply all
Reply to author
Forward
0 new messages