java - Cassandra 批量查询与单次插入性能

标签 java cassandra datastax

我使用 Cassandra java 驱动程序

我每秒收到 150k 个请求,我将这些请求插入到具有不同分区键的 8 个表中。

我的问题是哪种方法更好:

  • 批量插入这些表
  • 一个一个插入

我问这个问题是因为,考虑到我的请求大小 (150k),批处理听起来是更好的选择,但因为所有表都有不同的分区键,批处理看起来很昂贵。

最佳答案

请从以下链接查看我的回答:

Cassandra batch query performance on tables having different partition keys

批处理不是为了提高性能。它们用于确保原子性和隔离性。

Batching can be effective for single partition write operations. But batches are often mistakenly used in an attempt to optimize performance. Depending on the batch operation, the performance may actually worsen.

https://docs.datastax.com/en/cql/3.3/cql/cql_using/useBatch.html

如果这些表之间不需要数据一致性,那么使用单插入。 单个请求在节点之间正确分布或传播(取决于负载平衡策略)。如果您担心请求处理并使用批处理,批处理会给协调器节点带来如此多的额外工作负担,我猜这效率不高:)

关于java - Cassandra 批量查询与单次插入性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42930498/

相关文章:

java - 检查字符串是否包含我想要的字母以及末尾的空格

database - 我应该升级 Apache Cassandra 吗?

Docker 中的 Cassandra

python - 无法使用 DataStax Python 驱动程序远程连接到 Cassandra

java - Eclipse中Android开发如何避免 "Refreshing external Folders"

java - CPU 份额对线程的影响是什么

java - 如何在PreparedStatement中添加order by?

java - Spring JPA : PropertyReferenceException: No property findAll found for type

java - 可以通过 Cassandra Datastax 驱动程序从文件加载语句吗?

cassandra - com.datastax.driver.core.exceptions.BusyPoolException