This is a presentation given on October 24 by Michael Uzquiano of Cloud CMS (http://www.cloudcms.com) at the MongoDB Boston conference.
In this presentation, we cover Hazelcast - an in-memory data grid that provides distributed object persistence across multiple nodes in a cluster. When backed by MongoDB, objects are naturally written to Mongo by Hazelcast. The integration points are clean and easy to implement.
We cover a few simple cases along with code samples to provide the MongoDB community with some ideas of how to integrate Hazelcast into their own MongoDB Java applications.
4. • The fastest, easiest and most cost-effective way
to build cloud-connected web and mobile
applications.
• An application server in the cloud for cloud-
connected applications
• Built to leverage the strengths of MongoDB
• Hosted or On-Premise
12. Mobile Ready
• iOS, Android, Windows Mobile
• JavaScript, Java, PHP, Ruby, Node.js
• jQuery, jQuery Mobile, Dojo, YUI,
Sencha Touch, Titanium,
PhoneGap
13.
14. The right tool for the job
• JSON
• Query and Indexing
• Doesn’t overstep into application domain
• No transactions
• No referential integrity
• No triggers, foreign keys, procedures
• Gets out of the way so we can tackle these
15. Community + Momentum
• Really great language drivers
• Community contributors
• Frequent release schedule
• Exciting roadmap
16. Performance
• Very fast
• Anywhere from 2 to 10x faster than MySQL
• About 50 times faster than CouchDB
• Lots of benchmarks but the point is, it’s fast!
• Sharding built-in, automatic, and *Just Works™
• *Just Works™ guarantee applies only if you have a cluster of shard replica sets
with config servers and routing servers and you define your own shard key(s) with
appropriate uniformity and granularity
• Asynchronous replication for
redundancy/failover
17.
18. What is Hazelcast?
• In-Memory Data Grid (IMDG)
• Clustering and highly scalable data distribution
solution for Java
• Distributed Data Structures for Java
• Distributed Hashtable (DHT) and more
19. What does Hazelcast do?
• Scale your application
• Share data across cluster
• Partition your data
• Send/receive messages
• Balance load across cluster
• Process in parallel on many JVM
20. Advantages
• Open source (Apache License)
• Super light, simple, no-dependency
• Distributed/partitioned implementation of map,
queue, set, list, lock and executor service
• Transactional (JCA support)
• Topic for pub/sub messaging
• Cluster info and membership events
• Dynamic clustering, backup, fail-over
21. Data Partitioning in a Cluster
If you have 5 million objects in your 5-node cluster,
then each node will carry
1 million objects and 1 million backup objects.
Server1 Server2 Server3 Server4 Server5
22. SuperClient in a Cluster
• -Dhazelcast.super.client=true
• As fast as any member in the cluster
• Holds no-data
Server1 Server2 Server3 Server4 Server5
35. Distributed Job Queue
Upload of a 20 page PDF
Write PDF to GridFS
Add 2 jobs to Queue
(each to build 10 pngs)
36. Distributed Job Queue
Upload of a 20 page PDF
Write PDF to GridFS
Add 2 jobs to Queue
(each to build 10 pngs)
37. Distributed Job Queue
Upload of a 20 page PDF
Write PDF to GridFS
Add 2 jobs to Queue
(each to build 10 pngs)
38. Distributed Job Queue
Upload of a 20 page PDF
Write PDF to GridFS
Add 2 jobs to Queue
(each to build 10 pngs)
39. Distributed Job Queue
Jobs may run asynchronously
(returns once transaction complete)
Picks job from Picks Job from
queue and works on it queue and works on it
Job Scheduler determines
which jobs get priority
56. Spring Framework
• Spring Data for MongoDB
• http://www.springsource.org/spring-data/mongodb
• com.hazelcast.spring.mongodb.MongoMapStore
• Based on Spring API Template pattern
• com.hazelcast.spring.mongodb.MongoTemplate
• Easy to get started, base implementation
• You still might want to roll your own