Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

michael.shatz_192704 avatar image
michael.shatz_192704 asked ·

How do I increase the connection pool size that has reached the maximum of 256?

Hi,

The request fails on following error:

io.cyanite.api request process exceptioncom.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /<IP>:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [/<IP>] Pool is busy (no available connection and the queue has reached its max size 256))) 

Can you please advise how to increase the Pull Size

Thanks

Michael

java driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

The BusyPoolException gets thrown when all the connections in the pool are used and there are no available slots left. This can happen when:

  • an application is sending multiple long-running requests that eventually tie up all the connections in the pool until there are none left, or
  • the nodes are overloaded and requests are queueing up.

The driver will attempt to connect to nodes in the query plan one by one but when they're all busy and there are no nodes left to contact in the list, the driver will return the NoHostAvailableException.

Trying to increase the connection pool size won't achieve the outcome you're after simply because the nodes are already overloaded and adding more requests to the queue will just make it worse.

You need to review your queries and make sure you are only doing single-partition requests. You also need to throttle the traffic to make sure you are not overloading the cluster. Cheers!

6 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Hi @Erick Ramirez

Thanks for your answer.

Even though, can you please guide how to increase the pool size?

Thanks

0 Likes 0 ·

See Connection pooling in the driver docs.

0 Likes 0 ·

Hi

I set the following attributes in cassandra.yaml
max_connections_per_host=1000 and
max_requests_per_connection=1024

Cassandra restarted

But the above did not help, The BusyPoolException has been thrown.

Please advise

Thanks

0 Likes 0 ·

I feel like you've missed the point in my answer. Let me use an analogy.

Imagine you have 3 cashiers at a fast food restaurant taking orders and there are 10 customers queued up at each cashier (30 in total). But the cooks out the back can only serve 20 orders at a time so they can't keep up with the orders from 30 customers (leading to the "busy queue" problem).

Adding more cashiers out the front won't actually solve the problem because the size of the customer queues won't make a difference -- the problem is there's not enough capacity in the kitchen to process the orders.

In your case, your cluster can only service X transactions per second (tps) but your application is sending X + Y tps. You need to increase the size of your cluster to account for the extra Y tps. Cheers!

0 Likes 0 ·

Hi Erick,

I really appreciate your quick replies to all my questions, but none of them did really helped me
(note: I understand perfectly your answers).

I just want to know how to change the following attributes: max_connections_per_host and
max_requests_per_connection - that's all I want to know

thanks

0 Likes 0 ·
Show more comments