令牌感知Astyanax连接池在节点上连接,而无需在节点上分布连接 [英] Token Aware Astyanax Connection pool connecting on nodes without distributing connections over nodes
问题描述
我正在使用astyanax连接池,其定义如下:
I was using astyanax connection pool defined as this:
ipSeeds = "LOAD_BALANCER_HOST:9160";
conPool.setSeeds(ipSeeds)
.setDiscoveryType(NodeDiscoveryType.TOKEN_AWARE)
.setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE);
但是,我的集群有4个节点,并且有8个客户端计算机在其上连接. LOAD_BALANCER_HOST
将请求转发到我的四个节点之一.
However, my cluster have 4 nodes and I have 8 client machines connecting on it. LOAD_BALANCER_HOST
forwards requests to one of my four nodes.
在客户端节点上,我有:
On a client node, I have:
$netstat -an | grep 9160 | awk '{print $5}' | sort |uniq -c
235 node1:9160
680 node2:9160
4 node3:9160
4 node4:9160
因此,尽管ConnectionPoolType为TOKEN_AWARE
,但我的客户端似乎主要连接到node2,有时连接到node1,但几乎从未连接到节点3和4.
问题是:
为什么会这样呢?令牌识别连接池是否不应该在环中查询节点列表并使用轮询算法连接到所有活动节点?
So although the ConnectionPoolType is TOKEN_AWARE
, my client seems to be connecting mainly to node2, sometimes to node1, but almost never to nodes 3 and 4.
Question is:
Why is this happening? Shouldn't a token aware connection pool query the ring for the node list and connect to all the active nodes using round robin algorithm?
推荐答案
William Price
是完全正确的:您使用的是TokenAwarePolicy
并且可能使用默认的Partitioner
表示
-首先,您的数据将在各个节点之间有偏差地存储,并且
-然后在查询LoadbalancingPolicy
时,使您的驱动程序记住要询问的正确节点
William Price
is totally right: the fact you're using a TokenAwarePolicy
and possibly a default Partitioner
means that
- first your data will be stored biased across your nodes and
- then on querying the LoadbalancingPolicy
makes your driver remember the correct nodes to ask for
您可以通过使用一些偏差来提高群集的性能,或者可以使用自定义分区来平均分配数据.要随机查询节点,请使用
You can improve your cluster's performance by using some deviating or may be a custom partitioner to equally distribute your data. To randomly query nodes use either
RoundRobinPolicy
(http://www.datastax.com/doc-source/developer/java-apidocs/com/datastax/driver/core/policies/RoundRobinPolicy.html) orDatacenterAwareRoundRobinPolicy
(http://www.datastax.com/doc-source/developer/java-apidocs/com/datastax/driver/core/policies/DCAwareRoundRobinPolicy.html).
当然,后者需要在键空间中定义数据中心.
The latter, of course, needs the definition of data centers in your keyspace.
在没有任何更多信息的情况下,我建议仅更改分区程序,因为TokenAware负载平衡策略通常是一个好主意.最终,主要的负载将最终落在这些节点上-TokenAware策略将使您更快地到达正确的协调器.
Without any further information I would suggest to just change the partitioner as a TokenAware load balancing policy is usually a good idea. The main load will end up on these nodes in the end -- the TokenAware policy get's you to the right coordinator just quicker.
这篇关于令牌感知Astyanax连接池在节点上连接,而无需在节点上分布连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!