CRDB is Redislabs - Geo-Replicated, (Strong) Eventually Consistent CRDTs based Redis.
This presentation was give as part of RedisConf 2017 San Fransisco.
5. The 3 base requirements
1.Scale the same data set globally
2.Redis speed
3.No change to application
6. App
Scaling multi region redis challenge - Consensus?
Redis is fast: > 1,000,000 ops/sec, < 1 mSec
latency
Network east-west RTT is even slower > 70 mSec
Consensus requires clusters coordination which is
too slow for Redis
LWW by itself, can't solve Redis complex data-
type conflicts
7. The solution in a nutshell
Redislabs CRDB
Geo-Replicated
(Strong) Eventually Consistent
CRDTs based Redis
Conflict free Resolved DataBase | Cross Region DataBase | Cluster Replicated DataBase
8. Redis Replication
Been there forever...
Master -> Slave(s) model
Slave may be a master for other slaves
Constructed for High Availability (switch roles)
10. Redis Modules
● Since 4.0
● Dynamic libraries loaded to Redis
● With a C API
● Can extend Redis with:
New Capabilities
New Commands
New Data Types
10
11. CRDTs
Conflict Free Replicated Data Types (CRDTs)
• Years of academic research
• Based on consensus free protocol
• Strong eventual consistency
• Built to resolve conflicts with complex data
types
• Mostly transparent to users
Commutative
DAG
CmRDT
12. Reaching (Strong) Eventual Consistency with CRDT
1. Local ops: Reads & Writes locally
2. Async replication: Writes ops asynchronously replicated to all replicas
3. Consistency: CRDT model guarantees that the data-set would converge
to the same values, regardless of the order
Partial inconsistency - In any given time, the reads may yield different values,
but eventually (dependent on network latency) the values would converge
Simplify conflicts identifications - Maintain partial global ordering (identify
concurrent ops) = vector clocks
13. Vector Clocks for partial global ordering
A
B
C
{A=1,B=0,C=0}
{A=1,B=1,C=0}
{A=0}
{B=0}
{C=0}
{A=0,B=0,C=1} {A=0,B=0,C=2}
{A=1,B=2,C=0}
{A=0,B=0,C=3}
{A=1,B=3,C=3}
{A=2,B=3,C=3}
14. CRDB building blocks
Building block #1 - Redis Replication
Building block #2 - Redise Replica-Of for geo cluster replication
Building block #4 - Internal CRDT engine - strong eventual consistency
Building block #3 - Redis Modules
15. All together - CRDB: CRDT over Redise
Conflict free Resolved DataBase | Cross Region DataBase | Cluster Replicated DataBase
App
App App
CRDT
Module
CRDT
Module
CRDT
Module
1. Local read/writes
where clients use
regular redis commands
3. Bi-directional secured and
compressed async replica-of
a.k.a peer-replication
2. CRDTs implemented using
Redis Module
16. Demo
1. 1 geo distributed DB, replicated over 3 clusters
(replicas) on 3 regions: us-east, us-west, eu-west
2. Each Redise cluster generate load with
memtier_benchmark and a custom-built web-app.
3. To achieve Strong (without consensus protocol)
eventual consistency
● Operations are replicated between all replicas
(bi-directional and compressed)
● Use conflict free data types
<add image of the
items view>
17. The benefits
Support different network topology
Support different cluster topologies as
well as scaling local DB as needed
RingFully-Connected
Performance is as fast as regular local redis
and enhanced globaly by replicas count
19. Example setup
App
AppReplica A Replica B
Two replicas, working over single data sets
Each step is done concurrently and then a synchronization takes
place
Then we present the reconciled value on both replica
28. STRINGS: Last Write Wins
App
AppReplica A Replica B
> SET mykey “A”
OK
Syncing
Synced
> GET mykey
“A”
> GET mykey
1) “B”
> GET mykey
1) “B”
> GET mykey
“B”
> SET mykey “B”
OK
Replica B write time is later the replica A
29. STRING: Add wins / Observed remove
App
AppReplica A Replica B
> DEL mykey
(integer)
> SET mykey “C”
OK
Syncing
Synced
> GET mykey
(nil)
> GET mykey
“C”
> GET mykey
“C”
> GET mykey
“C”
32. Status and
Availability
Preview state
1.Strings (Registers)
2.Counters
3.Sets
4.Pub-Sub
5.Expiry
6.Hashes
Preview in the next few month
Contact pm.group@redislabs.com
To enroll
GA with next version of RePack and
Re Cloud Private and
(2017)
I’m Elad and I’m the VP of R&D for redislabs over the last couple of years.
What I’ll attempt in the following 45 min is to give you an overview on the concept of multi-master geo distributed redis solution we have.
Redis is fast, we all know that, but when you add traffic over network, we all know that we add the network latency.
Our customers are not looking just to scale a DB over Geo Regons, they want it to be Redis Fast.
In the session today, I’ll speak about the ability to scale redis over multiple geographical regions in multi-master manner: meaning enjoying local latency and performance while scaling data-set globaly.
Anyof you need redis to scale across geo regions
Not just scaling a DB over Geo Regions.
Keep speed when scaling
needs to scale globally.
Avoid latency ⇒ distribute DB on multiple regions
Converge data (conflict resolutions and consistency)
It is important to emphasis that the work is done on the same keys.
Though the types might change, it shouldn’t effect the client side
Redis is fast, but we need to keep it as fast when scaling it geographically
The basic of the solution is a bi-derctional compressed replication of
I assume all are familiar with this.
Replication is LOCAL.
Elaborat that the HA is so that the master and slaves can switch roles between them on a situation of failover
As for replication can be read write, if I mention it, we need to explain the problems with full sync where we’ll either loose consistency with master or loose what the master written
This is already global
Replica-Of feature.
Encapsulated databases.
Wan Optimization.
Can support different cluster topologies
This is used for running CRDTs, which also shows the strength of the modules as a solution.
No change on the users application
By show of hands, how many are familiar with CRDT concept?
Semilattice
idempotent (f(f(x)) = f(x)
Commutative axb = bxa
associative (ax(bxc) = (axb)xc),
Explain what we mean by mostly,
For example If you use list as a stack, you can’t promise that you concurrently in the same replica, the same element can’t pop more then once, to implement it we need a kind of cross region semaphores.
Expiry (the concept of expiry win)
Eventual Consistency => Local reads and writes, NO SYNC.
Redis Replication is similar
Different copies of dataset - CONVERGE EVENTUALLY.
Track CAUSE and EFFECT
Casual = meaning that there is some order, one operation was done after or before another.
Effect with vector clocks, enables this causality, it means that all entries of of one replica is >= another replica, and at least one is different. If not, we can know that the operations are concurrent.
When we identify concurrent operation we handle them differently to achieve consistency:
Registers = LWW | Add wins | Expiry wins |
Explain that the replication is based on proven replica-of mechanism which is used in Redis enterprise for a long time.
Speak about the demo structure a bit.
Add direct contact to the redis itself and send some commands to the DB and show them on the other one such as:
Sets -
Strings -
Counters -
PubSub -
I won’t get into the details of how we acheive the actual implementation, I will keep it from a user’s point of view.
Note that types changes are not supported at the moment, so a counter needs to be set only with incrby, in the future we’ll enable some modifications for that
Took both of the incrementations into account
Multi value as the counter is saved with entry per replica.
The deletion will be done for the values it was aware of only.
The add wins concept won and created that at the end the X value added on replica A will win
The deletes worked only on what was viewed by on the time of delete, so X was removed, while Y wasn’t as it was not observed on the time of the removal
Since the writes were done concurrently, the last write time wins and the value is “B”
The key is set to C though the delete took place the change wasn’t oserved by the deleting replica and it wasn’t deleted.
State that whoever would like to get a preview version, can contact our VP Product - Cihan