A Brief Guide to Aerospike XDR

Prashant Baisla
Prashant Baisla
5 min read
Posted on September 08, 2023
A Brief Guide to Aerospike XDR

Aerospike, a high-performance NoSQL database, offers a range of powerful features to meet the demands of modern data-intensive applications. One of its standout features is Cross-Datacenter Replication (XDR).

Here, we'll delve into what XDR is, its applications, its benefits, its limitations, and how to configure it.

What is XDR?

Cross-Datacenter Replication (XDR) is a robust data replication feature provided by Aerospike. It enables the synchronization of data across multiple geographically distributed data centers or clusters, ensuring data consistency, redundancy, and high availability.

Use Cases for XDR

XDR serves various purposes, making it a valuable tool for businesses across different industries:

Disaster Recovery

XDR ensures that data is replicated to a remote data center, providing disaster recovery capabilities. In case of a data center failure, the backup data center can take over seamlessly.

Global Distribution

For businesses with a global presence, XDR can be used to replicate data across multiple data centers worldwide, reducing latency and ensuring local access to data for customers.

Load Balancing

XDR can distribute read requests across multiple data centers, balancing the load and improving read performance.

Data Migration

When migrating from one data center to another or transitioning to a new cluster, XDR facilitates a smooth data migration process.

Capabilities of XDR

XDR can aid in handling many different replication scenarios. It allows flexibility in configuring replication to meet your specific use case. Some of these capabilities include:

Static and Dynamic Configuration

XDR can be configured statically in the configuration file or dynamically via the asadm or asinfo tools.

Configurable Replication Topology

Various replication topologies supported like active-passive, active-active, star, linear chain and any combination of these (hybrid).

Flexibility in Replication Granularity

You can choose to selectively replicate certain namespaces, sets or bins and this replication granularity can be defined differently for each data center.

Replicating Record Deletes

XDR can replicate deletes from clients and even from record expiration or eviction.

Cluster Heterogeneity

Clusters can be of different size, run on different types of machines, operating system, storage media etc.

Failure Handling

XDR provides graceful handling of node and network failures.

Compression

Compression can be enabled to save network bandwidth.

Rewinding Replication

You can rewind or rerun replication of records a specific number of seconds or restart replication completely.

Limitations of XDR

While XDR is a powerful feature, it may not be suitable for all scenarios. Here are some limitations and use cases where XDR might not be the best choice:

Network Latency

XDR relies on network connectivity between data centers. High network latency can impact the synchronization speed and performance.

Complexity

Setting up and managing XDR configurations, especially in active-active or fan-out scenarios, can be complex and require careful planning.

Consistency Guarantees in Mesh Topology

In a mesh or active-active topology, writes which happen in different data centers need to be replicated to amongst each other. Although XDR provides a feature called bin convergence which can help with write conflicts in such a setup, it cannot ensure eventual consistency and intermediate updates can be lost.

How to Configure an XDR Setup

So far, we’ve seen that XDR can support a myriad of use cases and configurations. Aerospike’s Documentation and Community Forum are excellent resources for learning how to setup XDR to meet your specific use case.

Let’s see how to setup an advanced use case involving dynamically configuring XDR in an active-active topology with bin convergence and password-based authentication for inter-cluster communication.

Cluster Configuration

The following is an example of Aerospike setup:

Instructions for setting up Aerospike clusters is out of scope for this blog. We assume that you already have the Aerospike clusters setup or well aware of how to do so. Ensure that your Aerospike clusters are correctly configured and have the necessary hardware and network infrastructure in place.

XDR Configuration

As mentioned before, XDR can be dynamically configured using the asadm and asinfo tools provided by Aerospike. We will use asadm in this example:

Login to each Aerospike node in each DC and create a password file which will be used for authentication. We will use the following credentials in this example:
Username: example-xdr
Password: example-xdr-password
Run the following command to create a password file:

echo 'example-xdr-password' > /path/to/password/file

Login to an Aerospike node in each DC and run the commands below. Unlike the previous step, we only need to do this once per Aerospike cluster as the configurations we set will be synced across the cluster.

######## Create a new user with XDR configuration and read-write privliges ########
asadm -U admin -P # Enter admin password when prompted
enable
manage acl create role xdr-role priv sys-admin read-write-udf
manage acl create user example-xdr password example-xdr-password roles xdr-role
exit

####### Login as example-xdr user ########
asadm -U example-xdr -P # Enter example-xdr-password when prompted
enable

### Enable LUTs (last update timestamps) for each namespace to be replicated ###
manage config namespace example-namespace param conflict-resolve-writes to true

### Assign distinct id for each data center ###
manage config xdr param src-id to 1

### Create entry for data center to replicate data to ###
manage config xdr create dc DC2

### Add details for each node in DC2 ###
manage config xdr dc DC2 add node node1.dc2.examplexdr.com:3000
manage config xdr dc DC2 add node nodeN.dc2.examplexdr.com:3000

### Configure bin convergence for each namespace to be replicated ###
manage config xdr dc DC2 namespace example-namespace param bin-policy to only-changed
manage config xdr dc DC2 namespace example-namespace param ship-bin-luts to true

### Configure authentication for XDR ###
manage config xdr dc DC2 param auth-user to example-xdr
manage config xdr dc DC2 param auth-password-file to /path/to/password/file
manage config xdr dc DC2 param auth-mode to internal

### Enable XDR for each namespace ###
manage config xdr dc DC2 add namespace example-namespace

exit

Persist or statically configure the same configurations in the Aerospike configuration file. This will ensure that your XDR configuration is not lost between cluster restarts.

Monitoring

Make use of Aerospike’s Monitoring stack to monitor and validate the XDR setup and process. Make use of or take inspiration from this Grafana dashboard curated by Aerospike.

The following is an example of Aerospike XDR view dashboard:

Conclusion

Aerospike XDR is a versatile feature that empowers businesses to achieve data redundancy, global distribution, disaster recovery, and load balancing. By understanding its capabilities, limitations, and configuration requirements, organizations can harness the power of XDR to ensure high availability and seamless data synchronization across multiple data centers or clusters.