【发布时间】:2016-08-21 16:18:24
【问题描述】:
我想使用 Cassandra 数据库来存储来自测试站点的时间序列数据。我正在使用Pattern 2 from the "Getting started with Time Series Data Modeling" tutorial,但没有存储日期以将行大小限制为日期,而是作为int 计算自 1970-01-01 以来经过的天数,该值的时间戳是自纪元以来的纳秒(我们的一些测量设备非常精确,需要精确度)。我的值表如下所示:
CREATE TABLE values (channel_id INT, day INT, time BIGINT, value DOUBLE, PRIMARY KEY ((channel_id, day), time))
我创建了一个简单的基准,考虑到using asynchronity and prepared statements for batch loading instead of batches:
def valueBenchmark(numVals: Int): Unit = {
val vs = session.prepare(
"insert into values (channel_id, day, time, " +
"value) values (?, ?, ?, ?)")
val currentFutures = mutable.MutableList[ResultSetFuture]()
for(i <- 0 until numVals) {
currentFutures += session.executeAsync(vs.bind(-1: JInt,
i / 100000: JInt, i.toLong: JLong, 0.0: JDouble))
if(currentFutures.length >= 10000) {
currentFutures.foreach(_.getUninterruptibly)
currentFutures.clear()
}
}
if(currentFutures.nonEmpty) {
currentFutures.foreach(_.getUninterruptibly)
}
}
JInt、JLong 和 JDouble 分别只是 java.lang.Integer、java.lang.Long 和 java.lang.Double。
当我针对 1000 万个值运行此基准测试时,本地安装的单节点 Cassandra 大约需要两分钟。我的电脑配备了 16 GiB 的 RAM 和一个四核 i7 CPU。我觉得这很慢。这是 Cassandra 插入的正常性能吗?
我已经阅读了这些:
还有什么我可以检查的吗?
【问题讨论】:
-
能否在您的问题中添加您的 JVM 内存参数?