正确处理大量异步查询 [英] Handle correctly a big number of asynchronous queries

查看:64
本文介绍了正确处理大量异步查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须更新Cassandra表中的几千条记录,并且使用 executeAsync(BoundStatement)方法,但是出现错误池忙(没有可用的连接,队列已达到最大大小256)参见下面的全部详细信息。$

I have to update several thousand of records in a Cassandra table and I use executeAsync(BoundStatement) method however I got the error Pool is busy (no available connection and the queue has reached its max size 256) see below the full details.$

正确的最佳方法是什么处理这种执行方式?如何增加Cassandra查询队列的大小和队列中的等待时间?

What is the best way to correctly handle this type of execution? What about increasing the Cassandra query queue size and the wait time in the queue?

Exception in thread "Thread-6" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: cassandra2/172.18.0.17:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra2/172.18.0.17] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra4/172.18.0.18:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra4/172.18.0.18] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra1/172.18.0.11:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra1/172.18.0.11] Pool is busy (no available connection and the queue has reached its max size 256)))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:75)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:28)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:28)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:236)

我使用具有3个节点的群集,QUARUM一致性和复制因子为3 。

I use a cluster with 3 nodes, QUORUM consistency and replication factor of 3.

推荐答案

有两种选择:


  1. 调整连接池以实现群集的最高性能

  2. 限制异步查询的数量,以避免NoHostAvailableException。例如。如在此处描述

  1. Tune the connection pool to achieve maximum performance for your cluster
  2. Throttle the number of async queries to avoid NoHostAvailableException. E.g. as described here

这篇关于正确处理大量异步查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆