Java Driver 1.0 for Apache Cassandra

Connection options

There are three classes the driver uses to configure node connections.

Protocol options

Protocol options configure the port on which to connect to a Cassandra node and which type of compression to use.


Table 1. Protocol options
Option Description Default
port The port to connect to a Cassandra node on. 9042
compression What kind of compression to use when sending data to a node: either no compression or snappy. Snappy compression isoptimized for high speeds and reasonable compression. ProtocolOptions.Compression.NONE

Pooling options

The Java driver uses connections asynchronously, so multiple requests can be submitted on the same connection at the same time.


The driver only needs to maintain a relatively small number of connections to each Cassandra host. These options allow you to control how many connections are kept exactly. The defaults should be fine for most applications.

Table 2. Connection pooling options
Option Description Default value
coreConnectionsPerHost The core number of connections per host. 2 for HostDistance.LOCAL, 1 for HostDistance.REMOTE
maxConnectionPerHost The maximum number of connections per host. 8 for HostDistance.LOCAL, 2 for HostDistance.REMOTE
maxSimultaneousRequestsPerConnectionThreshold The number of simultaneous requests on all connections to an host after which more connections are created. 128
minSimultaneousRequestsPerConnectionThreshold The number of simultaneous requests on a connection below which connections in excess are reclaimed. 25

Socket options

Socket options configure the low-level sockets used to connect to nodes.


All but one of these socket options comes from the Java runtime library's SocketOptions class. The connectTimeoutMillis option though is from Netty's ChannelConfig class.

Table 3. Pooling options
Option Corresponds to Description
connectTimeoutMillis "connectTineoutMillis" The connect timeout in milliseconds for the underlying Netty channel.
receiveBufferSize A hint on the size of the buffer used to receive data.
reuseAddress Whether to allow the same port to be bound to multiple times.
sendBufferSize A hint on the size of the buffer used to send data.
soLinger When specified, disables the immediate return from a call to close() on a TCP socket.
tcpNoDelay Disables Nagle's algorithm on the underlying socket.