3

We have 6 node cluster where we deploy everything to one region on AWS with 3 Availability Zones. We are using Ec2Snitch which should distribute one replica in each availability zone. We use DataStax Java driver. Servers doing write and read are distributed in availability zones same as nodes are (1 server by AZ). What we want to achieve is best possible read performance, write for us is not that important in a sense that we need to write data but not necessary fast. We use replication factor 3 but read and write with consistency level ONE.

We are investigating shuffle replicas in TokenAwarePolicy. It is said in DataStax Java Driver that it can increase read performance but decrease write distribution.

First question is about shuffleReplicas implementation, I followed implementation of newQueryPlan method and what I figured out is that for replicas LinkedHashSet is used meaning that primary replica will be always preferred to non primary replica.

// Preserve order - primary replica will be first
Set<Host> replicas = new LinkedHashSet<Host>();

Just to confirm, that will mean that driver will always prefer to connect to node where primary replica is, to have it as coordinator, if we set shuffleReplicas to false, which can create hot spots?

Second question is about idea to separate connection to cluster, and for writes use shuffleReplicas on true, which will distribute evenly tokens across cluster and for read to use TokenAwarePolicy with shuffleReplicas on false to gain best possible reads, is this idea viable and do you see any problems with it?

We would like to have reads always from same availability zone to gain maximum possible speed while reading data. Is this better approach then leaving shuffleReplicas on true and letting cluster choose coordinator evenly. Idea can be also to use WhiteListPolicy which will select only nodes from same AZ to servers placed in that AZ which will result in local read but that can create hot spots.

4

1 回答 1

2

只是为了确认一下,如果我们将 shuffleReplicas 设置为 false,这将意味着驱动程序将始终更喜欢连接到主副本所在的节点,将其作为协调器,这会产生热点吗?

是的。但是请注意,只有当您的所有分区键都映射到同一个副本时,这才会创建热点;如果您的分区键均匀分布在令牌环上,那应该没问题。

第二个问题是关于分离与集群的连接的想法,对于写入使用 shuffleReplicas 为 true,这将在集群中均匀分布令牌,读取使用 TokenAwarePolicy 和 shuffleReplicas 为 false 以获得最佳读取,这个想法是否可行,你看到了吗有什么问题吗?

我看到的主要问题是驱动程序无法判断请求是“读取”还是“写入”,因此您必须编写自己的负载平衡策略,或者使用两个单独Cluster的实例,一个用于读取, 一个用于写入。

否则,设置shuffleReplicasfalse不一定意味着您将获得“最佳读数”。使用时要考虑的主要影响shuffleReplicas是最终一致性;当shuffleReplicas为真时,可以读取过时的值,例如,如果您以一致性 ONE 写入副本 1,然后以一致性 ONE 从副本 2 读取。我通常建议将读取和写入设置shuffleReplicastrue以将负载均匀分布在集群上,并调整一致性级别以在吞吐量与读取过时值的风险之间取得最佳平衡。

于 2016-03-08T10:46:35.810 回答