Three Strategies For Configuring WAN Replication

Problem

You have two sites for high availability / disaster recovery that you'd like to keep in sync with one another. The two sites are located in geographically separate areas connected by a WAN link.

Solution

There are three mechanisms offered by Terracotta to replicate your Ehcache. This recipe highlights the general approach taken by each of these three solutions.

Solution 1: Built-in Terracotta Active/Passive Replication

This is the simplest configuration of the three solutions. In this solution, the approach is to simply use the built-in replication capabilities of the Terracotta Server Array. In this solution, one Terracotta Server Array Instance is positioned in each data center. At any one moment only one Terracotta Server Instance is active. This solution is ideal for data centers that are connected by a high-speed WAN link and maximum simplicity is required.

Diagram of solution:

Characteristics

This solution has the following characteristics.

Reads

All reads are done from just the one active Terracotta Server Array Instance. This means that clients in data-center will read from the Terracotta Server Array using a LAN connection, and clients in the other data-center will read from the Terracotta Server Array using a WAN connection.

Writes

All writes are performed against just the one active Terracotta Server Array Instance. This means that one clients in one data-center will write to the Terracotta Server Array using a LAN connection, and clients in the other data-center will write to the Terracotta Server Array using a WAN connection.

Summary

Pros:

  • Simple
  • Easy to manage

Cons:

  • Requires fast WAN connection (both high throughput and low-latency)

Solution 2: Transactional Cache Manager Replication

This solution relies on Ehcache Transaction (JTA) support. In this configuration, two separate caches are created, each one is 'homed' to a specific data-center.

When a write is generated, it is written under a JTA transaction to ensure data integrity. The write is written to both caches, so that when the write completes, each data-center specific cache will have a copy of the write.

This solution trades off some write performance for high read performance. Executing a client level JTA transaction can result in slower performance than Terracotta's built-in replication scheme. The trade-off however results in the ability for both data-centers to read from a local cache for all reads.

This solution is ideal for applications where writes are infrequent and high read throughput and or low read-latency is required.

Diagram of solution:

Characteristics

This solution has the following characteristics.

Reads

All reads are done against a local cache / Terracotta Server Array

Writes

All writes are performed against both caches (one in the local LAN and one across the remote WAN) simultaneously transactionally using JTA.

Summary

Pros:

  • High read throughput (all reads are executed against local cache)
  • Low read latency (all reads are executed against local cache)

Cons:

  • An XA transaction manager is required
  • Write cost may be higher

Solution 3: Messaging based (AMQ) replication

This solution relies on a message bus to send replication events. The advantage of this solution over the previous two solutions is the ability to configure - and fine-tune - the characteristics and behavior of the replication. Using a custom replicator that reads updates from a local cache combined with the ability to schedule and/or batch replication can make replication across the WAN significantly more efficient.

Diagram of solution:

Characteristics

This solution has the following characteristics.

Reads

All reads are done against a local cache / Terracotta Server Array

Writes

All writes are done against a local cache for reliable updates. Write updates are collected and sent at a configurable frequency across the message bus.

This approach allows for batch scheduling and tuning of batch size so that updates can utilize the WAN link efficiently.

Summary

Pros:

  • High read throughput (all reads are executed against local cache)
  • Low read latency (all reads are executed against local cache)
  • Write replication is highly efficient and tunable

Cons:

  • A message bus is required

More Information

All three of the WAN recipe solutions are tested and live on production customer deployments. Due to the specific nature of WAN environments, Terracotta recommends that you inquire for more information on Terracotta Forums or contact a Terracotta Solutions Expert for further assistance.