+ All Categories
Home > Technology > Devoxx uk 2014 High performance in-memory Java with open source

Devoxx uk 2014 High performance in-memory Java with open source

Date post: 24-Jul-2015
Category:
Upload: david-brimley
View: 64 times
Download: 1 times
Share this document with a friend
32
@ dbrimley # DevoxxHazelcast High Performance In-Memory Java with Open Source David Brimley @dbrimley http://blog.hazelcast.com/ http://www.hazelcast.org/
Transcript
Page 1: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

High Performance In-Memory Java with Open Source

David Brimley @dbrimley http://blog.hazelcast.com/ http://www.hazelcast.org/

Page 2: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Who is this guy?

• Senior Solutions Architect for Hazelcast.

• 17 Years Java Development.

• Started out as a Cobol Programmer in 1988.

• Learnt to code Basic on a Vic-20 and BBC Model B.

• Oracle Coherence and Pivotal Gemfire.

Page 3: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

In Memory Java

• High Performance In Memory Java? It’s an IMDG!

• Getting to grips with Hazelcast, a tour of features.

• Some IMDG Tips!

Page 4: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

In Memory Java

• It’s 2 things really, the 2 C.

• Cache

• Compute

• The Magic is the D you stick in front…Distributed!

• DCache + DCompute = IMDG!

Page 5: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Evolution of IMDG

CACHE IN ONE PROCESS - A MAP, AGGHH OOM!

Page 6: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Evolution of IMDG

CACHE IN ONE PROCESS - WITH EVICTION

Page 7: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Evolution of IMDG

DISTRIBUTED CACHE

Page 8: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Evolution of IMDG

DISTRIBUTED COMPUTE

Page 9: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Evolution of IMDG

BIG DATA IMDG

Page 10: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Qualities of an IMDG

• It should be easy to scale, vertically and horizontally.

• It should be fault tolerant.

• It should be performant.

• It should have a easy to understand API.

Page 11: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Enter Hazelcast!• Java Collections & Queues - Distributed!

• Java Concurrency - Distributed!

• Persist to and Read from from Anything!(RDBMS,File,Hadoop,Cassandra,MongoDB)

• Predicate and SQL like queries!

• Topics(Pub/Sub)

• Rich Event Callbacks

Page 12: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

<dependency> <groupId>com.hazelcast</groupId> <artifactId>hazelcast</artifactId> <version>3.2.2</version> </dependency>

1. Starting a Hazelcast Cluster Node

Page 13: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

HazelcastInstance hz = Hazelcast.newHazelcastInstance();

2. Starting a Hazelcast Cluster Node

Page 14: Devoxx uk 2014   High performance in-memory Java with open source

@YourTwitterHandle@dbrimley#DevoxxHazelcast

Demo

Page 15: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Distributed Compute

• Executors

• EntryProcessor

• MapReduce

Page 16: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Executor can run anywhere

• IExecutorService

• Runnable or Callable

• Targeted execution in the grid (keys,members)

Page 17: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IExecutorService executor = hz.getExecutorService(“myEService");executor.execute(new EchoTask("foo"));

2. Java Executor, but Distributed!

Page 18: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

EntryProcessor

• Execute your code on an entry in an atomic way.

• You do not need any explicit lock on entry.

• Runs via IMap.

Page 19: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

/** * Applies the user defined EntryProcessor to the entry mapped by the key. * Returns the the object which is result of the process() method of EntryProcessor. */

Object executeOnKey(K key, EntryProcessor entryProcessor);

EntryProcessor via IMap

Page 20: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

MapReduce

• New in 3.2

• Hadoop like API.

• Aggregators in 3.3

• Scheduled Tasks in 3.4

Page 21: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

IMap<String,String> map = hazelcastInstance.getMap("articles");

KeyValueSource<String,String> source = KeyValueSource.fromMap(map);

Job<String, String> job = jobTracker.newJob( source );

ICompletableFuture<Map<String, Long>> future = job .mapper( new TokenizerMapper() ) .combiner( new WordCountCombinerFactory() ) .reducer( new WordCountReducerFactory() ) .submit();

MapReduce

Page 22: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Persist and Read from anywhere.

• Implement a MapStore interface.

• Configure your Map.

• Cache misses will read through to the store.

• Cache updates can persist to store (sync/async).

Page 23: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

<map name="aDistributedMap"> <map-store enabled="true"> <class-name>com.company.YourMapStore</class-name> <write-delay-seconds>30</write-delay-seconds> </map-store> <indexes> <index ordered="true">aValueProperty</index> </indexes> </map>

2. Configure (in XML,Spring or API)

Page 24: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

public class UserMapStore implements MapStore<Integer, User> {

public void store(Integer userKey, User user) { userDao.insertUser(user); } public User load(Integer userKey) { return userDao.getUser(userKey); }

…… (more methods like delete, loadAll)

2. Implement MapStore

Page 25: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

We like standards.

• Greg Luck, Hazelcast CTO is JSR107 co-spec lead.

• Hazelcast will be JSR107 compliant this summer.

• https://github.com/hazelcast/hazelcast/tree/jcache-preview

Page 26: Devoxx uk 2014   High performance in-memory Java with open source

@YourTwitterHandle@dbrimley#DevoxxHazelcast

Demo

Page 27: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Some IMDG Advice

• Don’t force in your RDBMS schema.

• Do you really need that transaction?

• Execute near the data.

• Use the right Serialisation interface.

• Tune your JVM.

Page 28: Devoxx uk 2014   High performance in-memory Java with open source

@YourTwitterHandle#DVXFR14{session hashtag} @dbrimley#DevoxxHazelcast

Summar

y

Page 29: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Powerful tool for many Use Cases

• Unscalable NoSQL or RDBMS fix.

• Compute Intensive Tasks

• Web Session Replication

• HA Services

• WAN Replication

Page 30: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Get Coding!

• hazelcast.org - for open source and downloads

• hazelcast.com - for pro support,papers & webinars

• github.com/hazelcast for sources

• github.com/hazelcast/hazelcast-code-samples

• follow me on twitter @dbrimley

Page 31: Devoxx uk 2014   High performance in-memory Java with open source

@YourTwitterHandle#DVXFR14{session hashtag} @dbrimley#DevoxxHazelcast

Q & A

Page 32: Devoxx uk 2014   High performance in-memory Java with open source

@dbrimley#DevoxxHazelcast

Thanks / Creative Commons

•Presentation Template — Guillaume LaForge

•The Queen — A prestigious heritage with some inspiration from The Sex Pistols and funny Devoxxians

•Girl with a Balloon — Banksy

•Tube — Michael Keen


Recommended