eh cache in kaunas jug

Post on 03-Sep-2014

225 Views

Category:

Software

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Saulius Tvarijonas presented EhCach

TRANSCRIPT

EhCacheTo Cache Or Not To Cache?

Kaunas JUG

Saulius Tvarijonas · saulius.tvarijonas@gmail.com

Wiki● Ehcache is a widely used open source Java distributed

cache for general purpose caching, Java EE and light-

weight containers

● Ehcache was originally developed by Greg Luck,

starting in 2003. In 2009, the project was purchased by

Terracotta

Will an Application Benefit from Caching?

Will an Application Benefit from Caching?

● Speeding up CPU-bound Applications

● Speeding up I/O-bound Applications

● Increased Application Scalability

Scaling

Topologies

● Standalone

● Distributed

● Replicated

Storage Options

● MemoryStore

● Off-HeapStore

● DiskStore

Cache Usage Patterns● cache-aside (or direct manipulation)

● cache-as-sor (a combination of read-through and write-x patterns)

● read-through

● write-through

● write-behind (or write-back)

● copy-cache

Cache Sizing● Bytes (maxBytesLocalHeap=”30M”)

● Count (maxEntriesLocalHeap)

● Percentage (maxBytesLocalHeap="40%")

Evic

tion

● Time To Live● Time To Idle● Eternal● Pinning● Overflow● memoryStoreEvictionPolicy

Cache Persistence

<cache>

<persistence strategy=”localRestartable|localTempSwap|none|distributed”

synchronousWrites=”false|true”/>

</cache>

Search

Replication

Rep

licat

ion

● RMI, JGroups, JMS

● Serialization of key at least required

● Automatic Peer Discovery (Multicast)

● Bootstrap

● Sync and ASync

● Puts, Updates, Removals,

UpdatesViaCopy

WAN Replication

BigMemory Max

BigMemory Max

● Persistent Application State

● High Availability

● Fast Restartability

● Scalability

● Search

Prod

ucts

JSR 107 Java Caching Standard

● javax.cache.Cache

● Java 6 required

● Included in Java 7 EE

Web Console

Web Console

● Real Time Statistics

● Live Configuration Updates

● Cache enable/disable/clear

● Charts

Test Storage Results

Type Total time

(Concurrent)HashMap 11ms

MemoryStore 39ms

Off-HeapStore 5800ms

DiskStore 11300ms

● Cache with 1k elements● Element size 500 bytes● Measuring getFromCache time (100k times)

EhCache 3.0

● Standard API JSR 107

● Generics, Java 8 ready

● Java 6 compatible

● Better configuration

Competitors

● Hazelcast

● Memcached

● Oracle Coherence

● Infinispan

● GemFire

● GridGain

Java Forever

Thank

You!

top related