在C ++驱动程序中一起配置Cassandra的TokenAware和LatencyAware策略 [英] Configuring Cassandra's TokenAware and LatencyAware policy together in C++ driver

查看:63
本文介绍了在C ++驱动程序中一起配置Cassandra的TokenAware和LatencyAware策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在了解了可用的不同负载平衡策略之后( https://datastax.github.io/cpp-driver/topics/configuration/),在我看来,为了获得最佳性能,尤其是在多数据中心集群中,应将令牌感知和延迟感知策略一起使用(性能上述文章的提示"部分.

After reading about the different load balancing policies available(https://datastax.github.io/cpp-driver/topics/configuration/), it seems to me that for best performance,particularly in multi data-center cluster, token-aware and latency-aware policy should be used together('Performance Tips' section of the above mentioned article).

根据我的理解(假设复制因子> 1),当我们将这两个策略一起使用时,客户端将计算查询中使用的主键的哈希值,然后基于延迟,它将选择最佳副本执行该查询.在给定的情况下这种理解正确吗?

As per my understanding(assuming replication factor > 1), when we'll use both of these policies together, then the client will calculate the hash of the primary key used in the query and then based on the latency, it will chose the best replica for execution of that query. Is this understanding correct in the given scenario?

我还想了解如何一起准确地实现/配置这两个策略.我是否只需要在C ++代码中一个接一个地启用两个策略?如果没有,有人可以共享用于同时启用这两个策略的代码段吗?

Also, I wanted to understand how exactly to implement/configure these 2 policies together. Do I need to just simply enable both policies one after the other in my C++ code? If not, can someone share the code snippet for enabling both the policies together?

推荐答案

是的,您的理解是正确的-您可以同时使用这两种策略.要启用它们-只需一起调用2个相应的功能,然后按文档中所述设置必要的设置即可.

Yes, your understanding is correct - you can use both policies together. To enable them - just call 2 corresponding functions together, and set necessary settings as described in documentation.

如果您有多个DC,那么也可以启用DC感知的负载平衡...

If you have several DCs then it makes sense also enable DC-aware load balancing...

这篇关于在C ++驱动程序中一起配置Cassandra的TokenAware和LatencyAware策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆