Skip to main content
Loading

Connecting with a client application

Overviewโ€‹

This page describes Aerospike cluster nodes and how to connect to them with a client application.

An Aerospike cluster consists of one or more nodes. To connect a client application with a cluster, you can give it a seed node or a list of seed nodes for the initial connection, and after that connection is established the application can discover the other nodes in the cluster.

Single seed nodeโ€‹

Provide the client with the IP address and port of a seed node, and after the client connects it discovers the other nodes in the cluster.

Java example:

import com.aerospike.client.AerospikeClient;

AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

Multiple seed nodesโ€‹

You can provide a client with a list of seed nodes. If the first one fails to connect, the client tries the subsequent nodes until it connects. This is known as round-robin DNS, or Resource Distribution Pool.

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Host;
import com.aerospike.client.policy.ClientPolicy;

Host[] hosts = new Host[] {
new Host("a.host", 3000),
new Host("another.host", 3000),
new Host("and.another.host", 3000)
};

AerospikeClient client = new AerospikeClient(new ClientPolicy(), hosts);

Using a URI instead of an IP addressโ€‹

If you provide the client with a domain name system URI, the client uses the URI to obtain the seed node's IP address.

One advantage of using a DNS entry as a seed node is that if a cluster goes down, the operations team can switch the DNS to point to a different cluster. The client keeps trying to connect until it succeeds.

Closing the connection and cleaning upโ€‹

Client libraries provide methods for closing connections when they are no longer needed, and for releasing the client's resources.

Client/server compatibilityโ€‹

Check that your client library version is fully compatible with your Aerospike server version with the client/server compatibility matrix.

Further readingโ€‹

For more information about client libraries and connecting to Aerospike clusters, see Client Libraries.