Download - IMDB Showdown - OrigoDB, Redis and Hekaton
![Page 2: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/2.jpg)
Speed of light vs spinning metal
What Time ScaleL1 Cache 0.5 ns 0.008 2 mL2 Cache 7 ns 0.23RAM 60 ns 1 240 m 1 second1K over Gbit network 10 µs 167 2.5 minutes4K read SSD 150 µs 2500Rotating disk seek 10 ms 167000 40000 km 46 hours
![Page 3: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/3.jpg)
Price/GB vs GB/Server 1980- 2015
8 USD
6.480.000 USD
0.001 GB
2000 GB
![Page 4: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/4.jpg)
In-memory stores
• VoltDB• MemSQL
• Hazelcast• Aerospike• Memcached• Oracle Coherence• Redis
• Oracle Times Ten• SQL Server
In-memory OLTP• SAP Hana
• OrigoDBKey/value
New SQL Hybrid
?
![Page 5: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/5.jpg)
1. SQL ServerIn-memory OLTP
![Page 6: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/6.jpg)
B-trees and Transactions
LOG
DATA 64KB blocks w 8x8KB pagesLogical BTREE of 8kb data pagesIn the buffer pool (cache)
BufferManager
Transactions append inserted, deleted, original and modified pages to the LOG
CHECKPOINT
![Page 7: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/7.jpg)
SQL Server In-memory OLTP
SP
Logging
Latches
Locks
Buffer Manager I/O
Native compiled SPs
Minimal Logging and checkpointing
Lock-free data structures
Multi-version Currency control
In Memory and Memory optimized data structures
![Page 8: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/8.jpg)
Sql Server In-memory OLTP
• Heka = Greek for 100• Transparent for application• Integrates with Sql Server but with limitations• Enterprise license• 5-30x performance gain
![Page 9: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/9.jpg)
Demo!
![Page 10: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/10.jpg)
2. RedisREmote DIctionary Server
![Page 11: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/11.jpg)
• Hybrid Key/Value store• Value -> String | List | Set | Hash | SortedSet• Predefined Commands -> SET | GET | HSET | ...• Persistence: Snapshots + AOF• Highly optimized C, fast algorithms
![Page 12: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/12.jpg)
Twitter using redis
INCR next_user_id //returns 1000HMSET user:1000 name bart password ¤¤¤hash¤¤¤HSET users bart 1000ZADD followers:1000 1401267618 1234ZADD following:1234 1401267618 1000INCR next_post_id => 10343HMSET post:10343 user 1000 time $time body ’Ay Caramba’RPUSH posts:1000 10343
![Page 13: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/13.jpg)
3. OrigoDBBuild faster systems faster
![Page 14: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/14.jpg)
What’s the problem?
ServiceLayer
DomainLayer
Data AccessLayer
RelationalModel
Views/SP’s
CacheX
![Page 15: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/15.jpg)
One simple idea...
Keep state in memoryPersist operations, not system state
s0 s1 s2op1 op2
Sn = apply(opn, Sn-1)
![Page 16: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/16.jpg)
... with many names
• System prevalance – Prevalyer, java• MongoDB op log• Redis AOF• Memory Image – Martin Fowler• VoltDB – logical logging• Akka persistence – logging per actor• Event Sourcing
![Page 17: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/17.jpg)
OrigoDB
Kernel
Engine
Model
Storage
App Code
Server
Command
Query
FileSqlEvent StoreCustom
ConsistencyIsolationconcurrency
Sends commands and queries
JournalingSnapshotsBinaryFormatterProtoBufJSON
tcpJSON/http
In-processcalls
Domain specificobject-graph
Domain specific operations
ReplicationAd-hoc queriesWeb uiConsole or win svc
![Page 18: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/18.jpg)
Complete history of events
• Point in time • Debugging• Restore• Queries
• Audit trail• New interpretations
![Page 19: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/19.jpg)
Example – the model[Serializable]public class CommerceModel : Model{ internal SortedDictionary<Guid, Customer> Customers { get; set; } internal SortedDictionary<Guid, Order> Orders { get; set; } internal SortedDictionary<Guid, Product> Products { get; set; }
public CommerceModel() { Customers = new SortedDictionary<Guid, Customer>(); Orders = new SortedDictionary<Guid, Order>(); Products = new SortedDictionary<Guid, Product>(); } }
![Page 20: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/20.jpg)
Command[Serializable]public class AddCustomer : Command<CommerceModel>{ public readonly Guid Id; public readonly string Name;
public AddCustomer(Guid id, String name) { Id = id; Name = name; }
public override void Execute(CommerceModel model) { if (model.Customers.ContainsKey(Id)) Abort("Duplicate customer id"); var customer = new Customer {Id = Id, Name = Name}; model.Customers.Add(Id, customer); }}
![Page 21: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/21.jpg)
Query[Serializable]
public class CustomerById : Query<CommerceModel, CustomerView>
{
public readonly Guid Id;
public CustomerById(Guid id)
{
Id = id;
}
public override CustomerView Execute(CommerceModel model)
{
if (!model.Customers.ContainsKey(Id)) throw new Exception("no such customer");
return new CustomerView(model.Customers[Id]);
}
}
![Page 22: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/22.jpg)
Start your engines!static void Main(string[] args)
{
var engine = Engine.For<CommerceModel>();
Guid id = Guid.NewGuid();
var customerCommand = new AddCustomer(id, "Homer");
engine.Execute(customerCommand);
var customerView = engine.Execute(new CustomerById(id));
Console.WriteLine(customerView.Name);
Console.WriteLine("{0} orders", customerView.OrderIds.Count);
Console.ReadLine();
}
![Page 23: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/23.jpg)
Demo!Geekstream
![Page 24: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/24.jpg)
4. ConclusionThe old, the new and the ugly
![Page 25: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/25.jpg)
100% ACID Out of the Box?
SQL Server Redis OrigoDBAtomicity NO NO YESConsistency NO NO YESIsolation NO YES YESDurability YES YES YES
![Page 26: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/26.jpg)
Comparison Matrix
SQL REDIS ORIGO
License/Cost $$ OSS/Free MIT/Free (+$)
Language TSQL Commands + Lua C#/LINQ
OLTP YES YES YES
OLAP (indexing) YES NO YES
In-process NO NO YES
Througput/latency 3 1 2
Modeling Relational Fixed Multi
Maturity 1 2 3
Size 250GB/DB Available RAM Available RAM
![Page 27: IMDB Showdown - OrigoDB, Redis and Hekaton](https://reader035.vdocuments.mx/reader035/viewer/2022062420/55caee5abb61eb8a4f8b4687/html5/thumbnails/27.jpg)
Thank you!
• Try Origo!• Contribute, it’s open source• http://origodb.com• @robertfriberg, [email protected]