Skip to content

Connection management

This guide explains how the Developer SDK manages connections to Aerospike clusters.

Connection architecture

┌─────────────────────────────────────────────────────────┐
│ Your Application │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Session │ │ Session │ │ Session │ (multiple) │
│ └────┬────┘ └────┬────┘ └────┬────┘ │
│ └────────────┼────────────┘ │
│ │ │
│ ┌─────┴─────┐ │
│ │ Cluster │ (shared connection pool) │
│ └─────┬─────┘ │
└────────────────────┼────────────────────────────────────┘
┌───────────┼───────────┐
│ │ │
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
│ Node 1 │ │ Node 2 │ │ Node 3 │ (Aerospike cluster)
└─────────┘ └─────────┘ └─────────┘

Cluster discovery

The client automatically discovers all nodes from seed hosts:

import com.aerospike.client.sdk.Cluster;
import com.aerospike.client.sdk.ClusterDefinition;
import com.aerospike.client.sdk.Host;
// Provide seed hosts - client discovers the full cluster
Cluster cluster = new ClusterDefinition(
new Host("seed1.example.com", 3000),
new Host("seed2.example.com", 3000) // Backup seed
).connect();
// Client now knows about all nodes in the cluster

Connection pooling

The Cluster maintains a pool of connections to each node:

  • Connections are reused across operations
  • Pool size adjusts based on load
  • Idle connections are cleaned up periodically

Node failure handling

When a node fails:

  1. Client detects failure via heartbeat or operation timeout
  2. Operations automatically retry on other nodes
  3. Client removes failed node from active pool
  4. When node recovers, client re-adds it

Monitoring connection health

// Check cluster health
ClusterStats stats = cluster.getStats();
System.out.println("Active nodes: " + stats.getActiveNodeCount());
System.out.println("Total connections: " + stats.getTotalConnections());

Best practices

  1. Reuse Cluster instances — Create once, share across your application
  2. Use multiple seed hosts — Ensures discovery even if one seed is down
  3. Close properly — Call cluster.close() on shutdown
  4. Monitor health — Track connection metrics in production

Next steps

Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?