关于 java:Cassandra 批量查询 vs 单次插入性能

Cassandra batch query vs single insert performance

我使用 Cassandra java driver.

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

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

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

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


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

Cassandra 对具有不同分区键的表的批量查询性能

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

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

如果这些表之间不需要数据一致性,则使用单次插入。
单个请求在节点之间正确分布或传播(取决于负载平衡策略)。如果您担心请求处理和使用批处理,批处理将在协调节点上负担很多额外的工作,我猜这不会是有效的:)


批次反而会对性能产生巨大影响。
据我了解,最适合您的解决方案是将每个分区键拆分为不同的列表,然后使用批处理语句。您将看到对性能的巨大影响。