data grids with oracle coherence
DESCRIPTION
An introduction to building data grids in Oracle CoherenceTRANSCRIPT
![Page 1: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/1.jpg)
![Page 2: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/2.jpg)
2
The Data Bottleneck – grid performance is coupled to how quickly it can send and receive data
General solution is to scale repository by replicating data across several machines.
But data replication does not scale...
… but data partitioning does.
Coherence has evolved functions for server side processing too.
These include tools for providing reliable, asynchronous, distributed work that can be collocated with data.
Coherence leverages these to provide the fastest, most scalable cache on the market.
Low latency access is facilitated by simplifying the contract.
![Page 3: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/3.jpg)
3
Client
DS Node
DS Node
DS Node
DS Node
Data Source
![Page 4: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/4.jpg)
4
Client
DS Node
DS Node
DS Node
DS Node
Data Source
DS Node
DS Node
DS Node
DS Node
Bottleneck
![Page 5: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/5.jpg)
5
![Page 6: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/6.jpg)
6
DB
DB DB
DB DB
DB Data on
Disk
• Data exists on a shared file system.
• Multiple machines add bandwidth and processing ability
![Page 7: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/7.jpg)
7
Copy 6
Copy 1 Copy 2
Copy 5 Copy 6
Copy 3 Data on
Disk
Greatly increases bandwidth available for reading data.
![Page 8: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/8.jpg)
8
Copy 6
Copy 1 Copy 2
Copy 5 Copy 6
Copy 3
Data is copied to different machines.
What is wrong with this architecture?
![Page 9: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/9.jpg)
9
Data on Disk
Record 1 = foo
Record 1 = foo
Record 1 = bar
Client Writes
Data
Becomes out of date
![Page 10: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/10.jpg)
10
Data on Disk
Record 1 = foo
Record 1 = foo
Record 1 = bar
Client Writes
Data
Lock Record 1
![Page 11: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/11.jpg)
11
Copy 6
Copy 1 Copy 2
Copy 5 Copy 4
Copy 3 Client Writes
Data Controller
All nodes must be locked before data can be written
=> The Distributed Locking Problem
![Page 12: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/12.jpg)
12
765, 769…
1, 2, 3… 97, 98, 99…
333, 334… 244, 245…
169, 170… Client
Each machine is responsible for a subset of the records. Each record
exists on only one machine.
![Page 13: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/13.jpg)
13
• Data volume will naturally increase with the number of machines in the cluster as the data only exists in one place.
• Writes are only ever sent to one machine (that holds the singleton piece of data being modified) so write latency scales with the cluster.
![Page 14: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/14.jpg)
14
• Oracle RAC
• Gigaspaces
• Terracotta
• Oracle Coherence
![Page 15: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/15.jpg)
15
Node
Node Node
Node Node
Node
![Page 16: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/16.jpg)
16
![Page 17: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/17.jpg)
17
The Post-It Note is a great example of Business Evolution – a product that starts its life in one role, but evolves into something else … otherwise known as Accidental Genius.
Coherence is another good example!!
![Page 18: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/18.jpg)
18
Node
Node Node
Node Node
Node Database Client
Client Client Near Cache
![Page 19: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/19.jpg)
19
![Page 20: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/20.jpg)
![Page 21: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/21.jpg)
21
All data is stored as key value pairs
[key1, value1]
[key2, value2]
[key3, value3]
[key4, value4]
[key5, value5]
[key6, value6]
![Page 22: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/22.jpg)
22
• DB used for persistence only - Coherence is typically prepopulated
• Caching is over two levels (server and client)
Node
Node Node
Node Node
Node Database
Write Asynchronous
Bulk load at start up
![Page 23: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/23.jpg)
23
Coherence does not support: - ACID - Joins (natively) - SQL*
Coherence works to a simpler
contract. It is efficient only for simple data access. As such it can do this one job quickly and scalably.
![Page 24: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/24.jpg)
24
What is RAC?
RAC is a clustered database which runs in parallel over several machines. It supports all the features of vanilla Oracle DB but has better scalability, fault tolerance and bandwidth.
DB
DB DB
DB DB
DB Cache Node
Cache Node
Cache Node
Cache Node
Cache Node
Cache Node
Clustered therefore fault tolerant and
scalable
Supports ACID, SQL etc
No disk access
![Page 25: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/25.jpg)
25
Fault Tolerant Scalable Fast
![Page 26: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/26.jpg)
26
Node
Node Node
Node Node
Node Database Async write behind Client
Client Client Near Cache
Near Cache kept Coherent via Proactive update/expiry of data as
it changes
Queries run in parallel where possible
(aggregations etc)
Objects held in serialised form
In-memory storage of data – no disk induced latencies (unless you want them).
![Page 27: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/27.jpg)
27
In Memory Cache
(Fragile)
DB
![Page 28: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/28.jpg)
28
Data is held on at least two machines. Thus, should one fail, the backup copy will still be available.
Node 6
Node 1 Node 2
Node 5 Node 4
Node 3
Node 2 Backup
The more machines, the faster failover will be!
![Page 29: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/29.jpg)
29
- Scale the application by adding commodity hardware
- Coherence automatically detects new cluster members
- Near-linear scalability due to partitioned data
Node
Node Node
Node Node Node
Node
Node
Number of nodes (n)
Processing / Storage / Bandwidth
![Page 30: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/30.jpg)
30
Not that resilient:
- Single machine failure will be tolerated.
- Concurrent machine failure will cause data loss.
Key Point: Resilience is sacrificed for speed
![Page 31: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/31.jpg)
31
• Coherence works to a simpler contract. It is efficient only for simple data access. As such it can do this one job quickly and scalably.
• Databases are constrained by the wealth of features they must implement. Most notably (from a latency perspective) ACID.
• In the bank we are often happy to sacrifice ACID etc for speed and scalability.
![Page 32: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/32.jpg)
32
Summary so far…
![Page 33: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/33.jpg)
33
Summary so far…
![Page 34: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/34.jpg)
34
Summary so far…
![Page 35: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/35.jpg)
![Page 36: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/36.jpg)
36
Node Node Node Node
Client
UDP
cache.get(“foo”)
Foo Well Known
Hashing Algorithm
![Page 37: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/37.jpg)
37
Client
Connection Proxy
Data Storage Process
Primary
Backup
Connection Proxy
Data Storage Process
Primary
Backup
Data Storage Process
Primary
Backup
Data Storage Process
Primary
Backup
myCache.put(“Key”,”Value”);!
![Page 38: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/38.jpg)
38
Data Storage Process Primary Node X
Backup Bar
Data Storage Process
Primary…
Backup…
Data Storage Process
Primary Bar
Primary Node X Backup Node X Backup Foo
Data Storage Process
Primary…
Backup… Redistribution
Repartioning
Node X
I think Node X has died
I think Node X has died
Death detection is vote based – there is no central management
Redistribution
Repartioning
Consensus
![Page 39: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/39.jpg)
39
Node
Node Node
Node Node
Node Client A
Near Cache
key1, val
Data Invalidation Message: value for key1 is now invalid
Client B cache.put(key1, SomethingNew)
cache.get(key1)
Near Cache (in-process)
![Page 40: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/40.jpg)
40
12 Network Hops (6 internal to cluster, 6 external to cluster)
765, 769…
1, 2, 3… 97, 98, 99…
333, 334… 244, 245…
169, 170… Client
Lock(Key3)
Process
Unlock(Key3)
![Page 41: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/41.jpg)
41
Client
cache.invoke(EP)
765, 769…
1, 2, 3… 97, 98…
333, 334… 244, 245…
169, 170…
Class Foo extends AbstractProcessor !
public Object process(Entry entry)!
public Map processAll(Set setEntries)!
EntryProcessor
Key is Locked
Key is Unlocked
Your code goes here
Analogous to: Stored Procedures
![Page 42: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/42.jpg)
42
4 Network Hops (2 internal to cluster, 2 external to cluster)
765, 769…
1, 2, 3… 97, 98, 99…
333, 334… 244, 245…
169, 170… Client cache.invoke(..)
cache.invoke("Key3",!
new ValueChangingEntryProcessor(“NewVal"));!
![Page 43: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/43.jpg)
43
Run any arbitrary piece of code on any or all of the nodes
Client service.execute(some code)
service.execute(new GCAgent(), null, null);!
Node
Node Node
Node Node
Node
Analogous to: Grid Task
![Page 44: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/44.jpg)
44
Analogous to: Triggers Backing Map Listeners / Triggers allow code to be run in response to a cache event such as an
entry being added, updated or deleted.
Client cache.put(foo)
765, 769…
1, 2, 3… 97, 98…
333, 334… 244, 245…
169, 170…
Class MapListener !
Public void entryInserted(MapEvent evt)!
public void entryUpdated(MapEvent evt)!
public void entryDeleted(MapEvent evt)!
MapListener
Key is Locked
Key is Unlocked
Your code goes here
![Page 45: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/45.jpg)
45
Analogous to: Triggers (but with fault tolerance and built in retry)
Client
cache.put(765, X)
765, 769…
1, 2, 3… 97, 98…
333, 334… 244, 245…
169, 170…
Class CacheStore !
public void store(Object key, Object val)!
public void erase(Object key)!
CacheStore
Retry Queue Exception Thrown
Database
Should multiple changes be made to
the same key they will be coalesced
![Page 46: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/46.jpg)
46
Invocable
Backing Map Listener
CacheStore
Entry Processor Locks the key
Takes Parameters
& Returns Values
Is Guaranteed
Called by client Called by Coherence
Coalesces changes
Responds to a cache event
![Page 47: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/47.jpg)
47
All cluster side programming must be done in Java. However clients can be: • Java
• C#
• C++
Serialisation is done to an intermediary binary format known as POF. This allows theoretical transformation from POF directly to any language. Currently only Java, C# and C++ are supported.
C# Object
Java Object
Node
Node Node
Node Node
Node
IPofSerialiser
PofSerialiser
![Page 48: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/48.jpg)
48
C# MyInvocable
Java Invocable Run on Server
Node
Node Node
Node Node
Node
Mapping via pof-config file
Data objects are marshalled as described in previous slide
![Page 49: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/49.jpg)
![Page 50: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/50.jpg)
50
Set up associations between affinity attributes so that they are stored on the same machine
Trades Market Data
Affinity attributes define mappings
between data
![Page 51: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/51.jpg)
51
Trades Market Data
Entry Processor
Price trade based on
market data
Trade and market data for the same ticker are
collocated
![Page 52: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/52.jpg)
![Page 53: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/53.jpg)
53
Public class foo{!
Public void bar(){!
!//do some stuff!
}!
}!
Send code to data
Public class foo{!
Public void bar(){!
!//do some stuff!
}!
}!
Send data to code
DATA
DATA
![Page 54: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/54.jpg)
54
Client
DS Node
DS Node
DS Node
DS Node
Node
Node Node
Node Node
Node
Data Layer: Coherence Cluster
Processing Layer: DataSynapse Grid
![Page 55: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/55.jpg)
55
Client Node
Node Node
Node Node
Node
Processes are performed on the node where data exists
![Page 56: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/56.jpg)
56
Client DS Node (Compute)
DB (Data)
Client Coherence
Data + Compute
![Page 57: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/57.jpg)
57
Feed Server
Trade Cache
Cache Store
Domain Processing
Update Trade
Entry Processor
![Page 58: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/58.jpg)
58
• Free distribution of processing across multiple machines
• Free fault tolerance
• Free scalability to potentially thousands of machines
A very enticing proposition for new applications
![Page 59: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/59.jpg)
59
Coherence is not suitable for large scale processor intensive tasks (think Monte Carlo simulations etc). Why?
• Compute grids provide much more control of the execution environment (priorities, a UI etc)
• The grid is far more scalable in terms of compute power (dynamic provisioning of engines etc).
• The grid is much cheaper (per core) than Coherence.
![Page 60: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/60.jpg)
60
![Page 61: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/61.jpg)
61
Copy 6
Copy 1 Copy 2
Copy 5 Copy 4
Copy 3 Client Writes
Data Controller
![Page 62: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/62.jpg)
62
765, 769…
1, 2, 3… 97, 98, 99…
333, 334… 244, 245…
169, 170… Client
![Page 63: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/63.jpg)
63
![Page 64: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/64.jpg)
64
In Memory Cache
(Fragile)
DB
![Page 65: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/65.jpg)
65
Trades Market Data
Client
1, 2, 3… 97, 98…
333, 334… 244, 245…
169, 170… Cache Store DB
Data affinity Reliable Processing
![Page 66: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/66.jpg)
66
So in conclusion…
![Page 67: Data Grids with Oracle Coherence](https://reader034.vdocuments.us/reader034/viewer/2022051818/5493c8d6b47959654d8b48fe/html5/thumbnails/67.jpg)
67
Summary so far…