高于datastax驱动程序

高于datastax驱动程序

本文介绍了cassandra数据库-提取时间高于Netflix Astyanax驱动程序,高于datastax驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从Netflix Astyanax迁移到Datastax驱动程序-详细信息如下

We are migrating from Netflix Astyanax to Datastax driver - the details are given below

使用的驱动程序:

astyanax-cassandra(由Netflix提供);版本1.56.37


datastax-driver-core;版本3.3.2

Java版本:jdk 1.8

Servlet容器:Jetty 9.x

Cassandra版本:2.0。 9

Java version: jdk 1.8
Servlet Container: Jetty 9.x
Cassandra version: 2.0.9

示例功能代码:

从UUID列表中,它使用in子句过滤并从cassandra db中获取数据。

sample functional code:
From UUID list it filters and fetches the data from cassandra db using an in clause.

 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;
    }

执行上述代码后,使用以下命令获取结果的响应时间大约为25ms Netflix Astyanax驱动程序,而Datastax驱动程序在500毫秒左右响应。
不同驱动程序的获取时间差异很大。
是否可以提高上述datastax版本的性能。

When the above piece of code is executed the response time of fetching the results take approx around 25ms using Netflix Astyanax driver while the Datastax driver responds in around 500ms.There is a wide difference in fetch time of the different drivers.Is there a way to improve the performance in the aforementioned datastax version.

推荐答案

我们不知道这是什么发生在 getSession 中,但是否有可能在第一次调用会话时连接会话?

We don't know what is happening in getSession, but is it possible it's connecting a session the first time it's called?

请确保您关注的是应用程序生命周期中的单个实例。

Make sure you're following best practices of initializing a session at application startup, and using a single instance for the lifetime of the application.

这篇关于cassandra数据库-提取时间高于Netflix Astyanax驱动程序,高于datastax驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 03:19