in-memory data grids essentials. oracle coherence
DESCRIPTION
TRANSCRIPT
Scalable eCommerce Platform Solutions
Scalable eCommerce Platform Solutions
In-Memory Data Grids Essentials. Oracle CoherenceVladimir KondraschenkoMax Myslyvtsev
Scalable eCommerce Platform Solutions
About me
Vladimir Kondraschenko
• Lead Java engineer• More than 10 years of hands on experience in
– software design and coding– technical leadership– development management
Scalable eCommerce Platform Solutions
Agenda
• Preconditions of using IMDG• Architecture overview– topology– distributed cache layer– local cache layer
• Cache operations• Persistence integration• Tips
Scalable eCommerce Platform Solutions
Different Solutions
Coherence
Scalable eCommerce Platform Solutions
Preconditions of Using IMDG
• Big amounts of data (10-100 GB)• Low latency• High availability• Distributed calculations
Scalable eCommerce Platform Solutions
Transport
Local Data
Architecture Layers
Transport
Local Data
Transport
Local Data
Transport
Local Data
Transport
Local Data
Shared Data
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
Transport LayerDiscovery and communication
Scalable eCommerce Platform Solutions
IMDG Topology
Scalable eCommerce Platform Solutions
Discovery• Multicast• Well-known address
Scalable eCommerce Platform Solutions
Discovery• Multicast• Well-known address
New
Scalable eCommerce Platform Solutions
Discovery• Multicast• Well-known address
WKA
WKA
New
Scalable eCommerce Platform Solutions
Communication• Custom protocols over TCP or UDP• Senior node• Heartbeats
– Cluster heartbeats– Node heartbeats
Senior
Scalable eCommerce Platform Solutions
Communication• Custom protocols over TCP or UDP• Senior node• Heartbeats
– Cluster heartbeats– Node heartbeats
Senior
Scalable eCommerce Platform Solutions
Communication• Custom protocols over TCP or UDP• Senior node• Heartbeats
– Cluster heartbeats– Node heartbeats
Senior
Scalable eCommerce Platform Solutions
Node Departure• TCP Ring• IP monitor• Timeout
Scalable eCommerce Platform Solutions
Node Departure• TCP Ring• IP monitor• Timeouts
Scalable eCommerce Platform Solutions
Node Departure• TCP Ring• IP monitor• Timeouts
Box1: IP 177.230.14.5
IP ping
Scalable eCommerce Platform Solutions
Node Departure• TCP Ring• IP monitor• Timeout
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
Shared Data LayerCluster-wide data
Scalable eCommerce Platform Solutions
Distributed Cache
Cluster
Client Node
Cache Interface
Storage Node
Data Storage
Cache Interface
Scalable eCommerce Platform Solutions
Cache Topology
• ReplicatedStorage 1
A
D
B
E
C
F
Storage 2
A
D
B
E
C
F
Storage 3
A
D
B
E
C
F
Storage 1
A
D
B
E
Storage 2
C
A
D
F
Storage 3
E
B
F
C
• Partitioned
Scalable eCommerce Platform Solutions
Storage 3
Repartitioning
Storage 1
A
D
B
E
Storage 3
E
B
F
CE
Storage 2
C
A
D
FF
FCEB
Scalable eCommerce Platform Solutions
CAP Theorem
C
A
P
Coherence Coherence
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
Get/Put/Remove, Query, Invocation, Map-Reduce
Cache operations
Scalable eCommerce Platform Solutions
Key hashing
Cache Operations: Put/Get
Storage 1 Storage 2
Client
Primary A
A B C D E F
• Client knows responsible storage– Key hash is used to find it
• Automatic backups
Backup A
Backup F Primary F
Scalable eCommerce Platform Solutions
Storage 2Storage 2Storage 1
Cache Operations: Query• Broadcast request
– Unless Query is Key-Associated• All entries are evaluated
– Unless Indexes are used
field1=10 or field2>70field1=10 and key=A
key:field1:field2:
D7080
key:field1:field2:
C5060
key:field1:field2:
B3040
key:field1:field2:
D7080
key:field1:field2:
C5060
key:field1:field2:
B3040
key:field1:field2:
A1020
Scalable eCommerce Platform Solutions
Cache Operations: Invocation/Entry Processor• Task is serialized and distributed
– May contain additional data• Configurable execution scope
– Specific nodes– All nodes– Nodes bound to data
Node 1 Node 2
Task Task
Client
Task
Scalable eCommerce Platform Solutions
• Data-bound mapping– By keys– By Query
• Parallel execution
Storage 2Storage 1
key:field1:field2:
A1020
key:field1:field2:
B3040
key:field1:field2:
C5060
key:field1:field2:
D7080
Cache Operations: Map-Reduce
sum(field2) where field1>20
40 60 80
180
key:field1:field2:
A1020
140
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
Persistence integration
Scalable eCommerce Platform Solutions
Synchronous Persistence Integration
• Read-through
• Write-through
StorageClient Durable Storage
Data Grid
Client Durable Storage
Data GridStorage
Scalable eCommerce Platform Solutions
• Refresh-ahead
• Write-behind
Asynchronous Persistence Integration
Storage QueueClient Durable Storage
Data Grid
Storage QueueClient Durable Storage
Data Grid
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
Local Data LayerNode-specific data
Scalable eCommerce Platform Solutions
Storage Storage
Node
Near Caching• Local access by primary key• Lazy population• Invalidation
– On entry change– By timeout
Near Cache
Distributed Cache
A
A B
Scalable eCommerce Platform Solutions
Continuous Caching• Local access by any Query• Eager population• Near real-time data
Storage Storage
Node
Continuous Cache
Distributed Cache
A B
A B
Scalable eCommerce Platform SolutionsScalable eCommerce Platform Solutions
TipsUsing Oracle Coherence in practice
Scalable eCommerce Platform Solutions
Before integrating Oracle Coherence• Do I really need IMDG or just a cache?• How large my cluster should be?• How much heap memory should be
configured for each node?• What GC configuration to use?• Do I have a relevant environment
to test my application?
Scalable eCommerce Platform Solutions
Memory usageLimit cache size• By binary size (per node)• By number of objects in cache (per node)
Estimate cache object memory consumption• Use BinaryMemoryCalculator• Remember about backup copies• Cache listeners (near cache, custom)
Scalable eCommerce Platform Solutions
Investigation & troubleshooting• Coherence Management Framework (JMX)
– view cluster and nodes settings– list caches (front and back) on each node– view cache dynamic metrics
• Coherence command-line tool– manage cache services– manipulate cache data
• Profiling and heap analysis– analyze heap dump– analyze GC logs
Scalable eCommerce Platform Solutions
Scalable eCommerce Platform Solutions
Thank you!Questions & Answers
Scalable eCommerce Platform Solutions
References• Workshop
– https://github.com/mmyslyvtsev/imdg-workshop• Coherence Knowledge Base
– http://coherence.oracle.com• Developers Guide
– http://docs.oracle.com/cd/E18686_01/coh.37/e18677/toc.htm• Book
– http://www.amazon.com/Oracle-Coherence-3-5-Aleksandar-Seovic/dp/1847196128