简体   繁体   English

Cassandra批量查询与单插入性能

[英]Cassandra batch query vs single insert performance

I use Cassandra java driver . 我使用Cassandra java driver

I receive 150k requests per second, which I insert to 8 tables having different partition keys. 我每秒收到150k请求,我将其插入到具有不同分区键的8个表中。

My question is which is a better way: 我的问题是哪种方式更好:

  • batch inserting to these tables 批量插入这些表
  • inserting one by one . 一个接一个地插入

I am asking this question because , considering my request size (150k), batch sounds like the better option but because all the tables have different partition keys, batch appears expensive. 我问这个问题是因为,考虑到我的请求大小(150k),批处理听起来像是更好的选项,但因为所有表都有不同的分区键,批处理看起来很昂贵。

Please check my answer from below link: 请从以下链接查看我的答案:

Cassandra batch query performance on tables having different partition keys Cassandra批处理查询具有不同分区键的表的性能

Batches are not for improving performance. 批次不是为了提高性能。 They are used for ensuring atomicity and isolation. 它们用于确保原子性和隔离。

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 https://docs.datastax.com/en/cql/3.3/cql/cql_using/useBatch.html

If data consistency is not needed among those tables, then use single insert. 如果这些表之间不需要数据一致性,则使用单个插入。 Single requests are distributed or propagated properly (depends on load balancing policy) among nodes. 单个请求在节点之间正确分布或传播(取决于负载平衡策略)。 If you are concerned about request handling and use batch, batches will burden so many extra works on coordinator nodes which will not be efficient I guess :) 如果您担心请求处理和使用批处理,批处理将在协调器节点上负担如此多的额外工作,这将是无效的我想:)

Batches have a HUGE impact on performance instead. 批次对性能产生巨大影响。 The sollution that best suits you as I understand to split into diffirent lists per partition keys and then use batch statements. 根据我的理解,最适合您的溶剂分为每个分区键的不同列表,然后使用批处理语句。 You will see a huge impact on performance. 您将看到对性能的巨大影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM