为密集 IO 操作优化 cassandra java/scala 驱动程序的配置?

Configuration to optimize cassandra java/scala driver for intensive IO operations?

我在 cassandra 上找不到池化选项的任何配置(使用 Scala,但我可以使用 Java 示例进行管理)。有人做过吗?

编辑:我正在使用 java driver with scala extra。我的目标是优化密集型 IO 应用程序(DB 读取查询)。

由于您处于 JVM 环境中,因此您可以通过 Scala 加载有效的 Java 配置。

您需要按照driver's documentation. Cassandra 2.0 uses protocol V2 that has limit on the amount of the in-flight requests, so you have only possibility to increase a number of connections opened from driver to Cassandra. By default, for protocol V2 it has 最少 2 个连接和最多 2 个连接中的说明进行调整。您可以使用以下代码将其增加到最少 4 个和最多 10 个:

PoolingOptions poolingOptions = new PoolingOptions();
poolingOptions
    .setConnectionsPerHost(HostDistance.LOCAL,  4, 10)
    .setConnectionsPerHost(HostDistance.REMOTE, 2, 4);

创建 Cluster/Session 对象时应添加选项:

Cluster cluster = Cluster.builder()
    .withContactPoints("127.0.0.1")
    .withPoolingOptions(poolingOptions)
    .build();