46
www.hazelcast.com /** * In-Memory Computing * Distributed Systems */

In-Memory Distributed Computing - Porto Tech Hub

Embed Size (px)

Citation preview

Page 1: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

/** * In-Memory Computing * Distributed Systems */

Page 2: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

DisclaimerThis presentation may include certain forward-looking statements and projections provided by the Company. Any such statements and projections reflect various

estimates and assumptions by the Company concerning anticipated results. These statements involve risks, uncertainties and assumptions and are based on the

current estimates and assumptions of the management of the Company as of the date of this presentation and are subject to uncertainty and changes. No

representations or warranties are made by the Company as to the accuracy of any such statements or projections. Whether or not any such forward-looking statements or projections are in fact achieved will depend upon future events some of which are not within the control of the Company. Accordingly, actual results may vary from the projected results and such variations may be material. Statements contained herein describing documents and agreements are summaries only and such summaries

are qualified in their entirety by reference to such documents and agreements.

Page 3: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Page 4: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Who’s that dude?

• Chris(toph) Engelbert • Twitter fanatic: @noctarius2k • Weird 9+ Java-Years • Performance, GC, Fairytales • Apache Committer • Gaming, Travel Management, …

Page 5: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Who’s that dude?

• Chris(toph) Engelbert • Twitter fanatic: @noctarius2k • Weird 9+ Java-Years • Performance, GC, Fairytales • Apache Committer • Gaming, Travel Management, …

The www.hazelcast.ninja

Page 6: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

DistributedComputing…

Page 7: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

ToasterServer 1

TV-Server 1Power

CoffeeMakerServer 1

Kettle Server 1

StoveServer 1

DistributedComputing…

Page 8: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

ToasterServer 1

TV-Server 1Power

CoffeeMakerServer 1

Kettle Server 1

StoveServer 1

Power GridServer 1, 2

DistributedComputing…

Page 9: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

… but what meansDistributed Computing?OOO

( )

Page 10: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Caching? Don’t you mean ‘Wasting Memory’?

L1 Cache Reference L2 Cache Reference Main Memory Reference 1K send over 1 Gbps Network 4K read from SSD Seek on Spinning Disk Send Packet CA->AMS->CA

0.5 ns 7 ns

100 ns 10,000 ns

150,000 ns 10,000,000 ns

150,000,000 ns

0.01 ms 0.15 ms

10 ms 150 ms

Page 11: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Evolution of:- Memory-Price- Memory-Size

Page 12: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Page 13: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Data Distribution(Partitioning / Sharding)

Page 14: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Data Distribution

String code = “sunnytechhub”

Map<String, TShirtDelivery> shirts = Maps.create()

shirts.put(code, new TShirtDelivery(“Your Address”))

Page 15: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Data Distribution

String code = “sunnytechhub”

Map<String, TShirtDelivery> shirts = Maps.create()

shirts.put(code, new TShirtDelivery(“Your Address”))

// Enter code at http://hazelcast.org/t-shirts :-)>

Page 16: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Data Distribution

String code = “sunnytechhub”

int hashcode = hash(code)

partitionId = hashcode % partitionCount

cluster.send(partitionId, code, delivery)

Page 17: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Data Distribution

int hashcode = hash(code)

partitionId = hashcode % partitionCount

cluster.send(partitionId, code, delivery)

Must be a consistent hash function

Partition count must be constant

Can be calculated, smart routing possible

Page 18: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

That was easy!But don’t tell anyone!

Page 19: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Parallelize Processing

Page 20: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Parallelize Processing

int[] values = [0..100000].map(randomInt())

int[][] blocks = split(values, 10000)

int[] subresult = blocks.foreach(_.sum())

int result = subresult.sum()

Page 21: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Parallelize Processing

int[][] blocks = split(values, 10000)

int[] subresult = blocks.foreach(_.sum())

int result = subresult.sum()

No mutation, only new values

Independently computable

Might split further down (fork-join, work-stealing)

Page 22: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

I told you:Easy Peasy!

Page 23: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Caching!

Page 24: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

http://gadizmo.com/roll-your-own-with-the-ham-dogger.php

Roll Your Own!Evolution Of Caching

Page 25: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Caches Are Simple!

public class Cache<K, V> { private final Map<K, V> cache = new CHM<>();

public void put(K key, V value) { cache.put(key, value); }

public V get(K key) { return cache.get(key); }

}

Page 26: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Even With TTL!

Page 27: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

And Auto-Cleanup

Page 28: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

What Is Wrong?

Page 29: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

What Is Wrong?

O(n)5 mio

Entries

Page 30: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Page 31: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Evolution Of Caching

Page 32: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Proprietary Cache!

Evolution Of Caching

Page 33: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Proprietary Cache!

Evolution Of Caching

Open Source

Page 34: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Proprietary Cache!

Evolution Of Caching

Open Source

Commercial

Page 35: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Proprietary Cache!

Evolution Of Caching

Open Source

Commercial

Stupidly Expensive

Page 36: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

JCache?Luke!I Am Your

(J)Cache!

Page 37: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Success!Feels like

Page 38: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Going to theHazelcast!

Page 39: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Hazelcast in 5 Facts• Java Collections API• Java Concurrency API

• Transparent Data Distribution• Drop-In Replacement

• Disruptively Simple(c) Rod Johnson (@springrod)

Page 40: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

http://technoodling.net/mili-power-crystal-battery-pack-review/

Terracotta /EHcache

OracleCoherence

Infinispan

JavaCollections

API

Hazelcast

Page 41: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

No need to ## care aboutProprietary APIs!

Page 42: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Time to be Happy!

Page 43: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Time to be Happy!

Apache License 2

Page 44: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

Time to be Happy!

www.hazelcast.org

Page 45: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com@noctarius2k

You can do it!

Page 46: In-Memory Distributed Computing - Porto Tech Hub

www.hazelcast.com

Thank You!Any Questions?

@noctarius2k http://www.sourceprojects.org

http://github.com/noctarius

@hazelcast http://www.hazelcast.com http://www.hazelcast.org

http://github.com/hazelcast