Business is changing quickly; customers are demanding a better application experience and increased satisfaction.  Customers enjoy and expect a fast browsing experience. Even slight page-loading delays can hurt business. Your site needs to be responsive and deliver page loads with low latency in today’s global economy.

In an active-active configuration, all the regions are actively serving read and write requests simultaneously. This architecture provides the following benefits:

  • Globally dispersed audience – It is advantageous to provide local processing over remote processing when support is needed for a geographically distributed customer base.  Local processing offers the lowest latencies, the best performance, and avoids wide area network access.
  • Read and Write anywhere – The ability to read and write the same record in any region, at any time.   This provides optimal usage of OCI resources, all the regions can serve writes as well as reads.
  • Seamless disaster recovery – it affords a high degree of disaster recovery flexibility, allowing you to route both read and write requests to any region in the event of a regional disaster.

A Global Active Table is a global logical table that eliminates the problematic and error-prone work of replicating data between regions, enabling developers to focus on application business logic.  All updates performed in one region are automatically propagated to all the other regions. But what about Conflict Detection and Resolution?

Learn more about Oracle NoSQL Global Active Tables deliver extreme performance for globally distributed applications

Conflict-Free Replicated Data Types

Implementing an active-active replication solution is not trivial. The key to success lies in real-time data movement, conflict detection and resolution, and support for heterogeneous environments. Of the three, conflict detection and resolution comes with the most complexity.  When multiple systems are processing transactions and the activity is shared across the systems, detecting and addressing conflicts becomes essential for any active-active replication configuration.  Oracle NoSQL has an in-built conflict resolution solution based on a last writer wins algorithm, which works great most of the time.  But what about the class of data objects where data values need to be converged across regions?

In certain situations, you would like to converge updates across regions, sum up the results, and present the summed-up results when applications ask to read the values.  A last-writer-wins strategy is not an optimal approach in this case.  How can this be handled?  Oracle NoSQL offers a mechanism called conflict-free replicated data type – CRDT for handling and computing global counters for developers, alleviating the burden of bookkeeping and tallying values across regions using global counters—no need to redesign or rewrite your application.

CRDTs are a family of replicated data types with a common set of properties that enable operations performed on them to always converge to a correct and consistent common state among all regional replicas. To ensure that conflicts never happen and cause problems in your applications, operations on CRDTs must respect a specific set of arithmetic properties.

There are multiple types of CRDTs and the first type that we have released in the Oracle NoSQL Database is the Positive-Negative (PN) Counter type. Other CRDTs may be built in the future.

To start, let’s go through an example based on this blog. We talked about a common telco use case – offering a “Family Plan.” With this option, an account owner and their family share the data usage on the plan. The account is allocated a data usage limit for a month that the entire family collectively uses. When the total data usage across all family members sharing the account reaches 90 percent of the data limit, the telecom provider will send an SMS alert to the account owner.

Note: Global Active Tables is an enhanced feature based on Multi-Region tables taking into account the challenges of a fully managed service in the cloud.

For this example, let’s say that there are three family members and these family members are in different geographic regions, separated by a large distance. The account owner gets an alert from the telecom provider when the account reaches the 90 percent threshold, notifying the account owner that overage fees may be charged if usage goes beyond the contracted limit.

The data is replicated in different regions, so each family member gets a local view of the data improving latency, throughput, and overall performance. That means there are multiple regions, and each has a copy of the data containing the details of the customer’s data usage. Their individual usage needs to be updated in different regions, and at any point in time, the total usage can be monitored.

A CRDT data type is ideal in this situation to do conflict-free tracking of the data usage across different regions. In the above example, an increment counter in a multi-region table will track the data usage in each region. The consolidated data usage is automatically computed for you when the CRDT value is read from the Oracle NoSQL Database Cloud Service.  Oracle NoSQL will automatically merge the delta values from each region.

In our telco family plan use case, the telecom provider can simply read the value of the “usage” CRDT column, compare this against the contracted amount for the account, and then decide to raise an SMS alert if necessary.  No complex bookkeeping or reconciliation is necessary for the telecom provider to implement.

This is all done for them by the Oracle NoSQL Database Cloud Service!

MR_COUNTER data type 

Oracle NoSQL Database has a CRDT datatype, called MR_COUNTER, for use with Global Active Tables. In a Global Active Table setup, a CRDT is a data type that can be replicated across servers where regions can be updated independently.  It is always possible to converge the CRDT to a correct common state. Changes in the regions are concurrent and not synchronized with one another. In short, CRDTs provide a way for concurrent modifications to be merged across regions without user intervention. The MR_COUNTER datatype is a subtype of the INTEGER, LONG, or NUMBER data type.

To ensure that conflicts never happen, operations on CRDTs must respect the commutative properties of addition. That is, CRDT updates must only be via addition or subtraction. In the case of the Positive-Negative (PN) Counter:

  • Only the DEFAULT value is allowed when inserting a new row.  Assigning an explicit value to the CRDT field during insert will throw an error because the commutative property will break.
  • Only increment and decrement operations are allowed when updating a row.

Global Active Tables and Conflict Free Replicated Data Type (CRDT)

Summary

In this blog, we discussed how vital conflict detection and resolution is in an active-active replication.

  • Oracle NoSQL Global Active Table solution enabling predictable low latency and response time from anywhere in the world
  • Oracle continues to improve the developer experience by introducing CRDTs that perform automatic merging and bookkeeping of value updates across regions, alleviating the pain of multi-region reconciliation from your app development experience.

A Global Active Table table is a global logical table that eliminates the problematic and error-prone work of replicating data between regions, enabling developers to focus on application business logic.