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
- 使用hadoop运行jar时的NoSuchMethodError Sets.newConcurrentHashSet()
- Cassandra如何选择节点发送请求?
- 使用Datastax API(使用新的二进制协议)升级/读入/读取Cassandra数据库
- 使用Datastax Cassandra本机Java客户端管理不同一致性级别的最佳实践
- 如何使用datastax java驱动程序有效地使用批量写入cassandra?
- 写入cassandra datastax驱动程序引发的超时
- .jfindClass中的错误(as.character(driverClass)):找不到类
- 主线程java.lang.NoClassDefFoundError中的exception
- Java,Spark和Cassandra java.lang.ClassCastException:com.datastax.driver.core.DefaultResultSetFuture无法转换为阴影