Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the DataStax Java Driver be safely used in EE containers?

The documentation of the com.datastax.driver.core.Session class states that

(...) Each session maintains multiple connections to the cluster nodes (...)

However, general advice for EE environments is to leave pooling and thread management to the container.

It seems to me that the DataStax driver, which is not primarily targeted at EE environments, violates this rule. This makes me worry whether the driver can be safely used in my EE application.

like image 585
Schroenser Avatar asked Nov 22 '13 08:11

Schroenser


2 Answers

I do remember that advice. I think that's an old recommendation meant to emphasize that in most of the cases the application should not try to do extra thread management for the container (the key word here is "container"). Also messing up with threads might lead to over utilizing the resources of your server. In the days of single/dual-cores that was quite important.

Anyways, today we have:

  1. more cores
  2. more applications that use an asynchronous model

The DataStax driver allows you to configure the max thread pool sizes so you can keep things under your control.

Concluding, I think it should be pretty safe to use the driver. You can tune the thread pool according to your app needs and server(s) resources.

like image 127
Alex Popescu Avatar answered Sep 20 '22 13:09

Alex Popescu


The advantage of having multiple connections, regardless of environment, is that the Java client is token aware. This means it knows where the data is in the cluster, and it can therefore fire off queries to the correct node, thereby avoiding unnecessary lookups to other nodes for data that node doesn't own. Additionally, the client is aware of the cluster and its state, and it can redirect failed requests to other nodes transparently. If you only maintained one connection to a single machine, your application would fire requests off naively.

like image 31
rs_atl Avatar answered Sep 20 '22 13:09

rs_atl