Cassandra写入性能测试(集群环境),cassandra性能测试
环境:五个服务器节点(实质是用xserver虚拟出的虚拟机)
master2 218G 29741MB(mem) 2core
slave1 438G 29741MB(mem) 2core
slave2 310G 29741MB(mem) 2core
slave4 366G 29741MB(mem) 2core
slave5 338G 29741MB(mem) 2core
cassandra内存调整如下(每个节点一致),版本为3.10。
memtable_heap_space_in_mb: 2048
memtable_offheap_space_in_mb: 2048
批量写入大小失败阈值为50kb JVM内存配置:
MAX_HEAP_SIZE="4G"
HEAP_NEWSIZE="800M"
表模式:
<dev_id, time, k1 .. k350, tag1 .. tag150>,其中tag*列为double, k* 列为boolean, dev_id与time为ASCII。
程序描述:
每 次一个insert,使用驱动为datastax/java-driver。写入时使用了BatchStatement。每次批量四个insert,测试 写入10240条记录(insert语句)。使用长连接,Cluster产生的session不关闭,每个insert产生一次 BoundStatement,并加入到batchstatement中,每批(4个insert)调用一次execute(),直到所有的批量执行完成 才统一关闭。这里没有使用连接池。
还有一种测试不使用batch,直接逐条写入。
运行结果:
逐条写入,共运行五次,每次处理10240个insert,用时如下:
Spending 47029 ms in general.
Spending 43375 ms in general.
Spending 41938 ms in general.
Spending 45987 ms in general.
Spending 47186 ms in general.
批量写入,共运行五次,每次处理10240个insert,每批次4条insert,用时如下:
Spending 41070 ms in general.
Spending 34927 ms in general.
Spending 37261 ms in general.
Spending 34880 ms in general.
Spending 37496 ms in general.
结论:
逐条写入平均每秒:113316.95点
逐条写入平均每个insert用时:4.41ms
批量写入平均每秒:137905.75点
批量写入平均每个insert用时:3.62ms
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。