nosql implementation - part 1 (velocity 2015)
TRANSCRIPT
NoSQL Implementations
Real-world designs explored by
Matt Brender
Aging Buckets
Emphasis on persisting data.Not a lot of data.
Possibility of conflict.
2
Aging Buckets
Problem
Difficult to know what user viewed who’s profile• Don’t want to heavily edit current database design• Want a simple, scalable solution
Solution
Buckets of relationships using sets (CRDT)• Allows for simultaneous writes without siblings• Denormalize and flatten data as JSON• Store in Riak, index with Solr
3
Aging Buckets
{
[“Beth” : “Tom”],[“Beth” : “Jim”],[“Beth” : “George”]
}
2015:05:27
{
[“George” : “Tom”],[“Beth” : “Jim”],[“George” : “Jim”]
}
2015:05:26
{
[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”]
}
2015:05:25
4
Aging Buckets
Riak
5
ClientClient
Client
Aging Buckets
Riak
6
ClientClient
Client
{ [“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
{ [“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
7
ClientClient
Client
{ [“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
8
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
9
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] } {
[“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
10
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] } {
[“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
11
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Tom”: “Jane”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] } {
[“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
12
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Tom”: “Jane”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Beth”, “Jane”]} {
[“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”] }
Aging Buckets
Riak
13
ClientClient
Client
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Tom”: “Jane”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Beth”, “Jane”]}
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Beth”, “Jane”]}
14
Bucket propertiesan important step in this case
➜ bin/riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
sets created
➜ bin/riak-admin bucket-type activate setssets has been activated
require ‘riak’Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] = 'sets'
Aging Buckets
{ [“Jane”: “Tom”], [“Tom” : “Beth”], [“Beth” : “Tom”], [“George” : “Jim”], [“Tom”: “Jane”], [“Beth”: “Jane”] }
15
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Tom”: “Jane”] }
{ [“Jane”: “Tom”],[“Tom” : “Beth”],[“Beth” : “Tom”],[“George” : “Jim”],[“Beth”, “Jane”]}
}set CRDT behavior