【问题标题】:cassandra database - fetch time is higher than Netflix Astyanax Driver than datastax drivercassandra 数据库 - 获取时间高于 Netflix Astyanax 驱动程序而不是 datastax 驱动程序
【发布时间】: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版本的性能。

【问题讨论】:

  • 不知道更多就很难回答 - 集群中有多少个节点,拓扑是什么,用于请求的一致性级别是什么......

标签: datastax cassandra-2.0


【解决方案1】:

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

确保您遵循best practices 在应用程序启动时初始化会话,并在应用程序的生命周期内使用单个实例。

【讨论】:

  • getSession函数从以下实现中获取会话Cluster.Builder clusterBuilder = Cluster.builder().withLoadBalancingPolicy(loadBalancingPolicy); clusterBuilder.withPort(cassandraPort) .addContactPoints(contactPoints) username = "xxxxx";密码 = "xxxxx"; cluster = clusterBuilder.withCredentials(用户名,密码).build(); session = cluster.connect(keyspaceName);
  • 负载均衡策略是什么?
  • DCAwareRoundRobinPolicy 用于负载均衡。
猜你喜欢
  • 2016-02-27
  • 2017-01-20
  • 2018-02-15
  • 2013-12-23
  • 2015-10-25
  • 2020-02-01
  • 2016-10-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多