Cassandra批处理查询具有不同分区键的表的性能

我有一个测试用例,我从客户端每秒收到150k请求。

我的测试用例需要将UNLOGGED batch插入多个表并具有不同的分区键

 BEGIN UNLOGGED BATCH update kspace.count_table set counter=counter+1 where source_id= 1 and name='source_name' and pname='Country' and ptype='text' and date='2017-03-20' and pvalue=textAsBlob('US') update kspace.count_table set counter=counter+1 where source_id= 1 and name='source_name' and pname='City' and ptype='text' and date='2017-03-20' and pvalue=textAsBlob('Dallas') update kspace.count_table set counter=counter+1 where source_id= 1 and name='source_name' and pname='State' and ptype='text' and date='2017-03-20' and pvalue=textAsBlob('Texas') update kspace.count_table set counter=counter+1 where source_id= 1 and name='source_name' and pname='SSN' and ptype='text' and date='2017-03-20' and pvalue=decimalAsBlob(000000000); update kspace.count_table set counter=counter+1 where source_id= 1 and name='source_name' and pname='Gender' and ptype='text' and date='2017-03-20' and pvalue=textAsBlob('Female') APPLY BATCH 

有没有比我现在关注的当前方式更好的方法?

因为目前,我批量插入可能存在于不同集群中的多个表,因为它们具有不同的分区键,并且据我所知,将批量查询插入到具有不同分区键的不同表中具有额外的权衡。

首先,了解批处理的用例非常重要。

批次经常被错误地用于尝试优化性能。

批处理用于维护多个表之间的数据一致性。 如果需要primefaces性,则使用记录的批次。 如果在您的情况下,这是一个计数器表,如果表中的计数不需要一致,那么不要使用批处理。 如果你的集群没问题,Cassandra确保所有的写入都是成功的。

未记录的批处理需要协调程序来管理插入,这会对协调程序节点造成沉重的负担。 如果其他节点拥有分区密钥,则协调器节点需要处理网络跃点,导致传送效率低下。 在更新同一分区键时使用未记录的批次。

请按照以下文章:

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

https://medium.com/@foundev/cassandra-batch-loading-without-the-batch-keyword-40f00e35e23e#.npmx2cnsq