【发布时间】:2020-12-21 15:08:50
【问题描述】:
我们正在从 Netflix Astyanax 迁移到 Datastax 驱动程序 - 详细信息如下
使用的驱动程序:
astyanax-cassandra(由 Netflix 提供);版本 1.56.37
datastax-驱动程序核心;版本 3.3.2
Java 版本:jdk 1.8
Servlet 容器:Jetty 9.x
Cassandra 版本:2.0.9
示例功能代码:
它从 UUID 列表中过滤并使用 in 子句从 cassandra db 中获取数据。
public boolean isColumnIdExists(List<UUID> attrList) {
boolean IdExists = true;
try {
Statement SEARCH_CQL = null;
{
// Build the statement with in clause using either of these
QueryBuilder api or
Prepared statment or
netflix api
//
}
final ResultSet resultSet = CassandraConnectUtil.getSession().execute(SEARCH_CQL);
for (Row row : asIterable(resultSet.iterator())) {
if (row.getTimestamp("deletedbytimestamp") == null) {
IdExists = true;
break;
}
}
} catch (Exception ex) {
throw new Exception("Exception", ex);
}
return IdExists;
}
执行上述代码时,使用 Netflix Astyanax 驱动程序获取结果的响应时间约为 25 毫秒,而 Datastax 驱动程序的响应时间约为 500 毫秒。 不同驱动程序的获取时间存在很大差异。 有没有办法提高上述datastax版本的性能。
【问题讨论】:
-
不知道更多就很难回答 - 集群中有多少个节点,拓扑是什么,用于请求的一致性级别是什么......