首页 > 解决方案 > difference between core connections and i/o threads in Datastax Cassandra C++ driver

问题描述

I set number of core connections per host using cass_cluster_set_max_connections_per_host() and i/o threads using cass_cluster_set_num_threads_io(). I see that my client host is establishing, core connections * num i/o threads, number of tcp connections with each host in my cluster using netstat command. I am wondering what is the difference between an i/o thread and a core connection? Also, if a client is communicating with Cassandra cluster of 10 hosts and number of core connections is set to 2, i/o threads is set to 4 then there are essentially 10*4*2, 80 connections established from a host to cluster - and this all in single session, how are those connections utilized? doesn't it seem extraneous?

I am trying to tune those values so if a cluster is connected by 100 hosts simultaneously then the speed wouldn't slow down. Or are those settings unrelated to speed? Any more information or links are appreciated!

标签: c++cassandradatastax

解决方案


这是此处存在的字段的官方文档

cass_cluster_set_num_threads_io:这是将处理查询请求的线程数。默认值:1

cass_cluster_set_max_connections_per_host:设置每个 IO 线程中每个服务器的最大连接数。默认值:2

我想知道 i/o 线程和核心连接有什么区别?

I/O 线程基本上负责做客户端和服务器之间的所有网络操作。因此,如果您有 1000 条消息等待网络操作,该线程将一一挑选请求并执行它们。默认值为 1。

一旦 I/O 线程选择了一条消息,它就会使用set_max_connections中指定的连接来发出请求。默认值为 2,以便 I/O 线程可以根据服务器延迟和吞吐量智能地切换连接。

我正在尝试调整这些值,因此如果一个集群同时由 100 个主机连接,那么速度不会减慢。

您可以保持最大连接不变并增加 i/o 线程的数量,或者以相反的方式进行缩放。两者之间没有明确的更好的方法。您需要进行基准测试,看看哪种方法适合您的情况。

我认为,如果您的请求数量较少但请求数量很大,那么增加连接数量更有意义,但仍然需要进行基准测试。

链接还提供了一些额外的信息。


推荐阅读