clustering java applications with terracotta and hazelcast
DESCRIPTION
Presentation prepared for JavaBreese in Odessa, Ukraine (18 May 2013)TRANSCRIPT
![Page 1: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/1.jpg)
CLUSTERING JAVA APPLICATIONS
WITH TERRACOTTA AND HAZELCAST
Boris Trofimov @ Sigma Ukraine
![Page 2: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/2.jpg)
Why clasterization
Terracotta
Hazelcast
Summary
Sigma Ukraine 2
AGENDA
![Page 3: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/3.jpg)
Sigma Ukraine 3
WHY CLASTERIZATION?
Moore's law is broken
Era of Big Data
![Page 4: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/4.jpg)
Application clusterization Horizontal scaling, vertical scaling, MapReduce, MPI,...
Data Claterization Distributed Data Exchanging Distributed Coordination Distributed Heap
Sigma Ukraine 4
KINDS OF CLASTERIZATION
![Page 5: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/5.jpg)
SOMETIMES IT'S HARD TO CHOOSE...
Sigma Ukraine 5
![Page 6: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/6.jpg)
Sigma Ukraine 6
![Page 7: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/7.jpg)
Maintained by private company
Supports Quartz and Ehcache
Terracota modes
Sigma Ukraine 7
ABOUT TERRACOTTA
![Page 8: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/8.jpg)
Sigma Ukraine 8
![Page 9: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/9.jpg)
BigMemory uses Ehcache as its main programming interface
Off-Heap without Garbage Collection Pauses
3 major bricks: CacheManager, Cache and Element
Serializable data classes
Sigma Ukraine 9
DISTRIBUTED CACHE MODE
![Page 10: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/10.jpg)
Sigma Ukraine 10
EXAMPLE — CONFIGURATION
![Page 11: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/11.jpg)
11
EXAMPLE CRUD
![Page 12: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/12.jpg)
12
EXAMPLE — IN-MEMORY SEARCH
![Page 13: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/13.jpg)
BigMemory GO vs BigMemory MAX
Might use Server Array
Respecting CA (CAP theorem)
Linear grouth
Sigma Ukraine 13
CLUSTERIZATION
![Page 14: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/14.jpg)
Sigma Ukraine 14
![Page 15: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/15.jpg)
Sigma Ukraine 15
HOW IT WORKS
Specify root objects
Launch terracotta server
Launch app instances
![Page 16: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/16.jpg)
Terracotta uses aspect-oriented technologies to adapt the application at class load time.
Terracotta does not use serialization.
DSO uses object identity, instrumented classes (byte-code instrumentation), object-graph roots, and cluster-wide locks to maintain data coherence
Distributed GC
Sigma Ukraine 16
DSO INTERNALS
![Page 17: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/17.jpg)
All Standard non-value types like maps, lists
POJO Objects
Synchronization Java objects like locks, semaphores
Sigma Ukraine 17
OBJECTS TO SYNC
![Page 18: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/18.jpg)
Sigma Ukraine 18
EXAMPLE — DEFINE CONFIGURATION
![Page 19: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/19.jpg)
Sigma Ukraine 19
EXAMPLE — CODE
![Page 20: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/20.jpg)
Start Terracotta Server (local or cluster)
Launch two Java application instances through terracotta script launcher.
Sigma Ukraine 20
EXAMPLE — LAUNCH
![Page 21: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/21.jpg)
Sharing ordinary objects
Legacy clastering
Distributed Cache
Hibernate 2nd Cache (through DSO)
Web Session clustering (through DSO)
Clastering read/write data with fast update
Sigma Ukraine 21
USE CASES
![Page 22: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/22.jpg)
Internal ACID Transactions
Only data changes are broadcast
Local caches
DSO- POJO transparent clasterizations
Monitoring Control tools
Sigma Ukraine 22
BENEFITS
![Page 23: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/23.jpg)
Sigma Ukraine 23
![Page 24: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/24.jpg)
InMemory Distributed Cache
Open Source solution
Supports own special distributed data structures
Supports locks and events
Might be slcaled out
Easy to use and integrate
All objects must be serializable
Supports standard collection interfaces
Sigma Ukraine 24
WHAT IS HAZELCAST
![Page 25: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/25.jpg)
Distributed Queue
Distributed Topic
Distributed Map
Distributed MultiMap
Distributed Set
Distributed List
Distributed Locks
Distribured Event (Listeners)
Distributed Topic (Hello JMS)
Distributed Semaphore
Distributed Executor Service
Sigma Ukraine 25
SUPPORTED DATA
![Page 26: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/26.jpg)
26
EXAMPLE — DISTRIBUTED MAP
![Page 27: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/27.jpg)
Partitioning with replicas
Scalable Peer-toPeer architecture
Availability over Consistency
Failover cluster
Native Client support
Sigma Ukraine 27
CLUSTERIZATION
![Page 28: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/28.jpg)
User ASID Transactions over several operations
It is free, unlimited community license *
Persistence
Search enhanced by user-defined indexes
Spring support (beans, cachable)
Simple interfaces in comparison to Terracotta BigMemory
Sigma Ukraine 28
BENEFITS
![Page 29: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/29.jpg)
Share data across cluster
Send/receive messages
Distributed Coordination (locks)
Hibernate 2nd Cache
Http Session Clustering with HazelcastWM (based on Servlet specification)
Sigma Ukraine 29
USE CASES
![Page 30: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/30.jpg)
Sigma Ukraine 30
SUMMARY
![Page 31: Clustering Java applications with Terracotta and Hazelcast](https://reader033.vdocuments.us/reader033/viewer/2022061103/540874748d7f7205088b47e1/html5/thumbnails/31.jpg)
Thank you for your attention!