• Save
Alex Snaps JEEConf Presentation
Upcoming SlideShare
Loading in...5
×
 

Alex Snaps JEEConf Presentation

on

  • 1,355 views

 

Statistics

Views

Total Views
1,355
Views on SlideShare
1,085
Embed Views
270

Actions

Likes
4
Downloads
7
Comments
1

6 Embeds 270

http://jeeconf.com 240
http://www.techgig.com 14
https://twitter.com 9
url_unknown 5
http://twitter.com 1
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • I was at this conference. I never seen a more professional presentation than it. It was cool.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • ImmutableValueElementCopyStrategy\n copies the element, not its value\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Alex Snaps JEEConf Presentation Alex Snaps JEEConf Presentation Presentation Transcript

  • Scaling up & out withEhcache and TerracottaAlex SnapsSenior Software Engineer — Terracotta, Inc.
  • What’s this all about ?Rethink caching, rethink access patterns and, finally …Know what solution is right for your application to deal with lots of data !
  • Agenda Ehcache ? Terracotta ? Data access patterns revisited Scaling Up vs. Out Consistency consideration Search Inversion of control (sort of!)Q&A JeeConf 2011 — Kiev 3
  • Who’s who ?… on Ehcache, Terracotta and… last & least, me.
  • Ehcache JeeConf 2011 — Kiev 5
  • Ehcache The most widely used performance library in Java – Used in over 70 percent of enterprise Java applications – 200k + production deployments – Embedded in most popular Java frameworks/apps. Hibernate, Spring, Liferay, JIRA, ColdFusion, Grails... JeeConf 2011 — Kiev 5
  • Ehcache The most widely used performance library in Java – Used in over 70 percent of enterprise Java applications – 200k + production deployments – Embedded in most popular Java frameworks/apps. Hibernate, Spring, Liferay, JIRA, ColdFusion, Grails... Fast JeeConf 2011 — Kiev 5
  • Ehcache The most widely used performance library in Java – Used in over 70 percent of enterprise Java applications – 200k + production deployments – Embedded in most popular Java frameworks/apps. Hibernate, Spring, Liferay, JIRA, ColdFusion, Grails... Fast Lightweight – Less than 1 MB – Easy to use API JeeConf 2011 — Kiev 5
  • Ehcache The most widely used performance library in Java – Used in over 70 percent of enterprise Java applications – 200k + production deployments – Embedded in most popular Java frameworks/apps. Hibernate, Spring, Liferay, JIRA, ColdFusion, Grails... Fast Lightweight – Less than 1 MB – Easy to use API Grows with your application with only two lines of configuration – Scale Up - BigMemory (100’s of Gig, in process, NO GC) – Scale Out - Clustering Platform (Up to 2 Terabytes, HA) JeeConf 2011 — Kiev 5
  • Ehcache The most widely used performance library in Java – Used in over 70 percent of enterprise Java applications – 200k + production deployments – Embedded in most popular Java frameworks/apps. Hibernate, Spring, Liferay, JIRA, ColdFusion, Grails... Fast Lightweight – Less than 1 MB – Easy to use API Grows with your application with only two lines of configuration – Scale Up - BigMemory (100’s of Gig, in process, NO GC) – Scale Out - Clustering Platform (Up to 2 Terabytes, HA) Fully backward compatible all the way back to 1.x JeeConf 2011 — Kiev 5
  • Terracotta JeeConf 2011 — Kiev 6
  • Terracotta Founded 2003 in San Francisco, CA JeeConf 2011 — Kiev 6
  • Terracotta Founded 2003 in San Francisco, CA Present in India, Europe and pretty much all over the globe! JeeConf 2011 — Kiev 6
  • Terracotta Founded 2003 in San Francisco, CA Present in India, Europe and pretty much all over the globe! Open source project that delivers Enterprise Java application scalability and availability JeeConf 2011 — Kiev 6
  • Terracotta Founded 2003 in San Francisco, CA Present in India, Europe and pretty much all over the globe! Open source project that delivers Enterprise Java application scalability and availability Products around : – Ehcache & Hibernate – Quartz Scheduler – Web Sessions – Terracotta Toolkit JeeConf 2011 — Kiev 6
  • About me … JeeConf 2011 — Kiev 7
  • About me … Senior Software Engineer at Terracotta – Working on Ehcache & Terracotta integration, – Quartz Enterprise Scheduler, – Terracotta toolkit JeeConf 2011 — Kiev 7
  • About me … Senior Software Engineer at Terracotta – Working on Ehcache & Terracotta integration, – Quartz Enterprise Scheduler, – Terracotta toolkit Contributed to – Hibernate – Unitils & dbMaintain – ... and a couple of long forgotten open source projects JeeConf 2011 — Kiev 7
  • About me … Senior Software Engineer at Terracotta – Working on Ehcache & Terracotta integration, – Quartz Enterprise Scheduler, – Terracotta toolkit Contributed to – Hibernate – Unitils & dbMaintain – ... and a couple of long forgotten open source projects Speak at JUGs & conferences – like Codemotion, jFokus, JavaOne, JavaZone, Devoxx, Jazoon, ... JeeConf 2011 — Kiev 7
  • Now to the fun part!Data access patterns revisited
  • Big Data ? JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? Its all about supporting your business growth. JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? Its all about supporting your business growth. – Growth in terms of schema evolution. JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? Its all about supporting your business growth. – Growth in terms of schema evolution. – Growth in terms of data storage. JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? Its all about supporting your business growth. – Growth in terms of schema evolution. – Growth in terms of data storage. Growth in terms of data processing. JeeConf 2011 — Kiev 9
  • Big Data ? Whats Big Data for you? Not a question of quantity. – Gigabytes? – Terabytes? – Petabytes? Its all about supporting your business growth. – Growth in terms of schema evolution. – Growth in terms of data storage. Growth in terms of data processing. Is your data stack capable of handling such a growth? JeeConf 2011 — Kiev 9
  • Where’s all that data ?Relational databases & friends
  • How do you access your database ? JeeConf 2011 — Kiev 11
  • How do you access your database ? JeeConf 2011 — Kiev 11
  • Caching JeeConf 2011 — Kiev 12
  • Caching  If going to the database is so expensive... ... we should just avoid it! JeeConf 2011 — Kiev 12
  • Caching  If going to the database is so expensive... ... we should just avoid it!  Put a cache in front of the database JeeConf 2011 — Kiev 12
  • Caching  If going to the database is so expensive... ... we should just avoid it!  Put a cache in front of the database JeeConf 2011 — Kiev 12
  • Caching  If going to the database is so expensive... ... we should just avoid it!  Put a cache in front of the database  Data remains closer to processing unit JeeConf 2011 — Kiev 12
  • Cache in front of the database JeeConf 2011 — Kiev 13
  • Cache in front of the database RDBMS READ Helps scale your read operations Cache READ PowerBook G4 JeeConf 2011 — Kiev 13
  • Cache in front of the database RDBMS READ Helps scale your read operations Cache – Writes go directly to the database WRITE READ PowerBook G4 JeeConf 2011 — Kiev 13
  • SoR aware caching What about multithreaded cache misses for a same key … – You want to avoid hitting the system of record twice! SelfPopulating caches know how to fetch data on misses – Blocking concurrent accesses to missing keys – While only one thread populates the Cache But what about invalidation ? JeeConf 2011 — Kiev 14
  • Cache in front of the database JeeConf 2011 — Kiev 15
  • Cache in front of the database Helps scale your read operations JeeConf 2011 — Kiev 15
  • Cache in front of the database Helps scale your read operations – Writes go directly to the database JeeConf 2011 — Kiev 15
  • Cache in front of the database Helps scale your read operations – Writes go directly to the database Introducing Cache Writers JeeConf 2011 — Kiev 15
  • Cache in front of the database Helps scale your read operations WRITE RDBMS READ – Writes go directly to the database Cache Introducing Cache Writers – Writes are being done to the Cache WRITE READ PowerBook G4 JeeConf 2011 — Kiev 15
  • Write-through RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-through RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-through RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-through RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-behind JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) • required for recovery in the face of failure JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) • required for recovery in the face of failure – Only write to database later JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) • required for recovery in the face of failure – Only write to database later • in batches and/or coalesced JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) • required for recovery in the face of failure – Only write to database later • in batches and/or coalesced In a distributed environment handling failures we enforce happens at least once JeeConf 2011 — Kiev 17
  • Write-behind Rather than write changes directly to the slowest participant – Write to faster durable store (persistent queue) • required for recovery in the face of failure – Only write to database later • in batches and/or coalesced In a distributed environment handling failures we enforce happens at least once – loosens the contract vs. "once and only once"! JeeConf 2011 — Kiev 17
  • Write-behind RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Writer Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind RDBMS Writer Cache Writer Application code JeeConf 2011 — Kiev
  • Write-behind JeeConf 2011 — Kiev 19
  • Write-behind Very configurable JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds – Retry configuration JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds – Retry configuration JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds – Retry configuration New as of Ehcache 2.4 JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds – Retry configuration New as of Ehcache 2.4 – writeBehindConcurrency="3" JeeConf 2011 — Kiev 19
  • Write-behind Very configurable – Batching & Coalescing – Maximum delay between each write – Limit the writes per seconds – Retry configuration New as of Ehcache 2.4 – writeBehindConcurrency="3" – writeBehindMaxQueueSize="500" JeeConf 2011 — Kiev 19
  • Scaling the database JeeConf 2011 — Kiev 20
  • Scaling the database JeeConf 2011 — Kiev 20
  • Scaling the cache JeeConf 2011 — Kiev 21
  • Scaling the cache JeeConf 2011 — Kiev 21
  • BigMemory JeeConf 2011 — Kiev 22
  • BigMemory OffHeap storage – But in process memory JeeConf 2011 — Kiev 22
  • BigMemory OffHeap storage – But in process memory Uses DirectByteBuffer JeeConf 2011 — Kiev 22
  • BigMemory OffHeap storage – But in process memory Uses DirectByteBuffer Faults unused elements out of heap, and in again, transparently – …and from or to the disk store as well JeeConf 2011 — Kiev 22
  • BigMemory OffHeap storage – But in process memory Uses DirectByteBuffer Faults unused elements out of heap, and in again, transparently – …and from or to the disk store as well Holds hundreds of gigabytes of data – 320Gb tested on a single machine JeeConf 2011 — Kiev 22
  • Large data on a single VM JeeConf 2011 — Kiev 23
  • Distributed Caching JeeConf 2011 — Kiev 24
  • Distributed Caching  What if data isnt perfectly partitioned ? JeeConf 2011 — Kiev 24
  • Distributed Caching  What if data isnt perfectly partitioned ?  How do we keep this all in sync ? JeeConf 2011 — Kiev 24
  • Distributed Caching  What if data isnt perfectly partitioned ?  How do we keep this all in sync ?  Peer-to-peer ? JeeConf 2011 — Kiev 24
  • Distributed Caching JeeConf 2011 — Kiev 25
  • Distributed Caching  Cached data remains close to the processing unit JeeConf 2011 — Kiev 25
  • Distributed Caching  Cached data remains close to the processing unit  Central unit orchestrates it all JeeConf 2011 — Kiev 25
  • Distributed Caching JeeConf 2011 — Kiev 26
  • Distributed Caching JeeConf 2011 — Kiev 27
  • Distributed Caching JeeConf 2011 — Kiev 28
  • DCV2 JeeConf 2011 — Kiev 29
  • DCV2 Simple storage change in the cache config – <terracotta storageStrategy=”DCV2” /> JeeConf 2011 — Kiev 29
  • DCV2 Simple storage change in the cache config – <terracotta storageStrategy=”DCV2” /> All keys and values are stored on the server – With a local cache (enabled by default) JeeConf 2011 — Kiev 29
  • DCV2 Simple storage change in the cache config – <terracotta storageStrategy=”DCV2” /> All keys and values are stored on the server – With a local cache (enabled by default) With a TSA – holds Terabytes of data! JeeConf 2011 — Kiev 29
  • Consistency considerationsFrom Happens-Before to ACID to 2PC and… back!
  • The ACID guarantees JeeConf 2011 — Kiev 31
  • The ACID guarantees Let people easily reason about the problem JeeConf 2011 — Kiev 31
  • The ACID guarantees Letpeople easily reason about the problem Atomic – We see all changes, or no changes at all JeeConf 2011 — Kiev 31
  • The ACID guarantees Letpeople easily reason about the problem Atomic – We see all changes, or no changes at all Consistent – Changes respect our rules and constraints JeeConf 2011 — Kiev 31
  • The ACID guarantees Letpeople easily reason about the problem Atomic – We see all changes, or no changes at all Consistent – Changes respect our rules and constraints Isolated – We see all changes as independently happening JeeConf 2011 — Kiev 31
  • The ACID guarantees Letpeople easily reason about the problem Atomic – We see all changes, or no changes at all Consistent – Changes respect our rules and constraints Isolated – We see all changes as independently happening Durable – We keep the effect of our changes forever JeeConf 2011 — Kiev 31
  • The ACID guarantees Letpeople easily reason about the problem Atomic – We see all changes, or no changes at all Consistent – Changes respect our rules and constraints Isolated – We see all changes as independently happening Durable – We keep the effect of our changes forever Fits a simplified model of our reality JeeConf 2011 — Kiev 31
  • ... and that’s what you get JeeConf 2011 — Kiev 32
  • ... and that’s what you get ... when using Hibernate – Using read-write strategy – Falls back to DB to resolve isolation level – Transactional leaves it to the cache to be ACI(D) • And requires an XA environment, including all overhead! JeeConf 2011 — Kiev 32
  • ... and that’s what you get ... when using Hibernate – Using read-write strategy – Falls back to DB to resolve isolation level – Transactional leaves it to the cache to be ACI(D) • And requires an XA environment, including all overhead! But using Ehcache API directly – Youget the JMM guarantees – Cached values are not inherently thread-safe JeeConf 2011 — Kiev 32
  • Basic tools JeeConf 2011 — Kiev 33
  • Basic tools Blocking & SelfPopulatingCache constructs – Will not let multiple threads populate the cache with the same key JeeConf 2011 — Kiev 33
  • Basic tools Blocking & SelfPopulatingCache constructs – Willnot let multiple threads populate the cache with the same key Explicit Locking API – acquire ( Read | Write ) LockOnKey – releaseLockOnKey – try ( Read | Write ) LockOnKey JeeConf 2011 — Kiev 33
  • Atomic Operations JeeConf 2011 — Kiev 34
  • Atomic Operations Atomic operations on Cache – putIfAbsent(Element): Element – removeElement(Element): Element – replace(Element, Element): boolean – replace(Element): boolean JeeConf 2011 — Kiev 34
  • Atomic Operations Atomic operations on Cache – putIfAbsent(Element): Element – removeElement(Element): Element – replace(Element, Element): boolean – replace(Element): boolean Copy on read & copy on write caches – Configurable per cache copyOnRead=”true” copyOnWrite=”false” – Configurable CopyStrategy per caches • Can be used with custom ElementValueComparator JeeConf 2011 — Kiev 34
  • Transactional caches JeeConf 2011 — Kiev 35
  • Transactional caches When you need rollback! JeeConf 2011 — Kiev 35
  • Transactional caches Whenyou need rollback! Comes in three flavors: – local – xa – xa_strict JeeConf 2011 — Kiev 35
  • Transactional caches Whenyou need rollback! Comes in three flavors: – local – xa – xa_strict Very simple configuration per Cache configuration – transactionalMode=”local” JeeConf 2011 — Kiev 35
  • Transactional caches Whenyou need rollback! Comes in three flavors: – local – xa – xa_strict Very simple configuration per Cache configuration – transactionalMode=”local” Only accessible within a Transaction JeeConf 2011 — Kiev 35
  • Transactional caches Whenyou need rollback! Comes in three flavors: – local – xa – xa_strict Very simple configuration per Cache configuration – transactionalMode=”local” Onlyaccessible within a Transaction They will copy on read and copy on write JeeConf 2011 — Kiev 35
  • Transactional caches Whenyou need rollback! Comes in three flavors: – local – xa – xa_strict Very simple configuration per Cache configuration – transactionalMode=”local” Onlyaccessible within a Transaction They will copy on read and copy on write When clustered, cache must be coherent JeeConf 2011 — Kiev 35
  • Local transaction JeeConf 2011 — Kiev 36
  • Local transaction Cheap! JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); cache1 = cacheManager.getEhcache("txCache1"); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); cache1 = cacheManager.getEhcache("txCache1"); cache1.put(new Element(1, putValue)); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); cache1 = cacheManager.getEhcache("txCache1"); cache1.put(new Element(1, putValue)); cache2 = cacheManager.getEhcache("txCache2"); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); cache1 = cacheManager.getEhcache("txCache1"); cache1.put(new Element(1, putValue)); cache2 = cacheManager.getEhcache("txCache2"); cache2.remove(“key”); JeeConf 2011 — Kiev 36
  • Local transaction Cheap! Requires you to do the demarcation transactionController = cacheManager.getTransactionController(); transactionController.begin(); cache1 = cacheManager.getEhcache("txCache1"); cache1.put(new Element(1, putValue)); cache2 = cacheManager.getEhcache("txCache2"); cache2.remove(“key”); transactionController.rollback(); JeeConf 2011 — Kiev 36
  • XA Caches JeeConf 2011 — Kiev 37
  • XA Caches What for ? – Synchronicity of data between Ehcache & other XA resources is guaranteed JeeConf 2011 — Kiev 37
  • XA Caches What for ? – Synchronicity of data between Ehcache & other XA resources is guaranteed How ? – Two phase commit JeeConf 2011 — Kiev 37
  • XA Caches What for ? – Synchronicity of data between Ehcache & other XA resources is guaranteed How ? – Two phase commit Java Transaction API to the rescue ! – JSR907 / Direct port of the X/Open XA standard – JTA is about reading and writing transactionally into multiple resources: • databases JMS servers, • caches, • or whatever is used to store or transport data – The transaction manager manages and drives XA resources JeeConf 2011 — Kiev 37
  • XA Caches JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction XA JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction XA – Will synchronize on the inflight XA Transaction JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction XA – Will synchronize on the inflight XA Transaction XA_STRICT JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction XA – Will synchronize on the inflight XA Transaction XA_STRICT – Will register a full blown XAResource with the TX JeeConf 2011 — Kiev 38
  • XA Caches READ_COMMITED isolation level Transactional Caches will : – Figure the TransactionManager out – Enlist in the Transaction automagically – Only be accessible within an inflight Transaction XA – Will synchronize on the inflight XA Transaction XA_STRICT – Will register a full blown XAResource with the TX • Including support for recovery JeeConf 2011 — Kiev 38
  • Sometimes,... you want less consistency JeeConf 2011 — Kiev 39
  • Sometimes,... you want less consistency When clustered, consistency comes at prices – That you might not always want to pay JeeConf 2011 — Kiev 39
  • Sometimes,... you want less consistency When clustered, consistency comes at prices – That you might not always want to pay Introducing eventual consistency – No lock involved – Client sends • updates asynchronously • send as batches to the server – Other client knowing about the value for a key, gets the updates pushed to by the server • Might see stale values for some milliseconds from local cache JeeConf 2011 — Kiev 39
  • Consistency types for clustered caches JeeConf 2011 — Kiev 40
  • Consistency types for clustered caches Also configurable per cache – Strong(JMM) – Eventual consistency • Will use the local cached value JeeConf 2011 — Kiev 40
  • Consistency types for clustered caches Also configurable per cache – Strong(JMM) – Eventual consistency • Will use the local cached value Non-stop caches – Lets you configure • Timeout on caches • Timeout behavior – noop – exception – local read JeeConf 2011 — Kiev 40
  • Consistency types for clustered caches Also configurable per cache – Strong(JMM) – Eventual consistency • Will use the local cached value Non-stop caches – Lets you configure • Timeout on caches • Timeout behavior – noop – exception – local read Rejoin JeeConf 2011 — Kiev 40
  • Where’s my data ?!… when key lookup isn’t enough
  • Key / Value JeeConf 2011 — Kiev 42
  • Key / Value Sometimes retrieving values only based on a key isn’t enough, because – You don’t know the key – The key / value paradigm simply doesn’t apply JeeConf 2011 — Kiev 42
  • Key / Value Sometimes retrieving values only based on a key isn’t enough, because – You don’t know the key – The key / value paradigm simply doesn’t apply Giventhe amount of data now storable Search was just the natural next step... JeeConf 2011 — Kiev 42
  • Introducing Ehcache Search JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API Provides fast, flexible access to every aspect of your in-memory data JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API Provides fast, flexible access to every aspect of your in-memory data Offloads queries from the database reducing the DB’s role as a bottleneck – Or adds search-ability to data that wasn’t before, like WS JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API Provides fast, flexible access to every aspect of your in-memory data Offloads queries from the database reducing the DB’s role as a bottleneck – Or adds search-ability to data that wasn’t before, like WS Improves application performance/latency JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API Provides fast, flexible access to every aspect of your in-memory data Offloads queries from the database reducing the DB’s role as a bottleneck – Or adds search-ability to data that wasn’t before, like WS Improves application performance/latency Works efficiently when standalone JeeConf 2011 — Kiev 43
  • Introducing Ehcache Search Ehcache Search is a querying capability built into the core OSS Ehcache API Provides fast, flexible access to every aspect of your in-memory data Offloads queries from the database reducing the DB’s role as a bottleneck – Or adds search-ability to data that wasn’t before, like WS Improves application performance/latency Works efficiently when standalone Scales out linearly with your data when distributed (O(Log n)/Server Count) without code changes JeeConf 2011 — Kiev 43
  • Two key concepts in search JeeConf 2011 — Kiev 44
  • Two key concepts in search Attributes – What can be searched JeeConf 2011 — Kiev 44
  • Two key concepts in search Attributes – What can be searched Queries – FluentObject Oriented interface used for searching the cache leveraging the defined Attributes JeeConf 2011 — Kiev 44
  • Attributes JeeConf 2011 — Kiev 45
  • Attributes Definition Types JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Beanattributes Bean style properties on the key or value JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Bean attributes Bean style properties on the key or value – Expressions Method calls and/or field accesses JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Bean attributes Bean style properties on the key or value – Expressions Method calls and/or field accesses – Custom Extractors A user defined class that can extract what ever you need for searching JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Bean attributes Bean style properties on the key or value – Expressions Method calls and/or field accesses – Custom Extractors A user defined class that can extract what ever you need for searching Definition Styles JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Bean attributes Bean style properties on the key or value – Expressions Method calls and/or field accesses – Custom Extractors A user defined class that can extract what ever you need for searching Definition Styles – XML JeeConf 2011 — Kiev 45
  • Attributes Definition Types – Bean attributes Bean style properties on the key or value – Expressions Method calls and/or field accesses – Custom Extractors A user defined class that can extract what ever you need for searching Definition Styles – XML – Code JeeConf 2011 — Kiev 45
  • Attribute definition XML <searchable> <!-- Bean style spec --> <searchAttribute name="age" /> <!-- Expression style spec --> <searchAttribute name="gender" expression="value.getGender()" /> <!-- Custom Extractor style spec --> <searchAttribute name="name" class="com.company.NameAttributeExtractor" /> </searchable> JeeConf 2011 — Kiev 46
  • Queries JeeConf 2011 — Kiev 47
  • Queries A fluent object oriented interface based on the defined Attributes. JeeConf 2011 — Kiev 47
  • Queries A fluent object oriented interface based on the defined Attributes. Aggregate – Sum, Average, Min, Max, Count JeeConf 2011 — Kiev 47
  • Queries A fluent object oriented interface based on the defined Attributes. Aggregate – Sum, Average, Min, Max, Count Match – ilike, eq, between, gt, lt, between etc JeeConf 2011 — Kiev 47
  • Queries A fluent object oriented interface based on the defined Attributes. Aggregate – Sum, Average, Min, Max, Count Match – ilike, eq, between, gt, lt, between etc Logical Operators – and, or, not JeeConf 2011 — Kiev 47
  • Queries A fluent object oriented interface based on the defined Attributes. Aggregate – Sum, Average, Min, Max, Count Match – ilike, eq, between, gt, lt, between etc Logical Operators – and, or, not Result Set Control – Ascending vs descending, max object counts, include keys/values, ranges JeeConf 2011 — Kiev 47
  • When moving data is not a good idea!Sending the work to data
  • Introducing Quartz Scheduler JeeConf 2011 — Kiev 49
  • Introducing Quartz Scheduler Lets you schedule asynchronous jobs JeeConf 2011 — Kiev 49
  • Introducing Quartz Scheduler Lets you schedule asynchronous jobs De facto scheduler for the Java Platform JeeConf 2011 — Kiev 49
  • Introducing Quartz Scheduler Lets you schedule asynchronous jobs De facto scheduler for the Java Platform Easily clusterable using Terracotta – Share scheduler across Cluster – Persistent storage for your jobs JeeConf 2011 — Kiev 49
  • One simple API JeeConf 2011 — Kiev
  • One simple API Job – Actual Job implementation – Defines what to execute – Think the script for a cron entry JeeConf 2011 — Kiev
  • One simple API Job – Actual Job implementation – Defines what to execute – Think the script for a cron entry public class MyJob implements Job { public void execute(final JobExecutionContext context) throws JobExecutionException { // Do the actual work } } JeeConf 2011 — Kiev
  • One simple API Job – Actual Job implementation – Defines what to execute – Think the script for a cron entry Triggers – Fire the Job for execution – Defines when to execute – Think the actual cron expression JeeConf 2011 — Kiev
  • One simple API Job – Actual Job implementation – Defines what to execute – Think the script for a cron entry Triggers – Fire the Job for execution – Defines when to execute – Think the actual cron expression Single API – To schedule Jobs & Triggers – That actually executes these Jobs JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM JVM SchedulerThread JVM JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM JVM SchedulerThread scheduler.scheduleJob(job, trigger); JVM JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM JVM SchedulerThread JVM JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM L1 JVM SchedulerThread L1 JVM L1 JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM L1 JVM SchedulerThread L1 JVM L1 JeeConf 2011 — Kiev
  • Quartz Where & Ehcache JVM JVM L1 JVM SchedulerThread L1 JVM L1 JeeConf 2011 — Kiev
  • I know… it’s late now!So, in summary
  • Summary JeeConf 2011 — Kiev 53
  • Summary Ehcache JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether • In terms of data sizes JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether • In terms of data sizes • Processing power JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether • In terms of data sizes • Processing power • Redundancy JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether • In terms of data sizes • Processing power • Redundancy • Persistency JeeConf 2011 — Kiev 53
  • Summary Ehcache – Scales your system of record today – Easily! Terracotta – Scales your cache when it needs it – Whether • In terms of data sizes • Processing power • Redundancy • Persistency All these features available with a couple lines of configuration only JeeConf 2011 — Kiev 53
  • ehcache | ehcache.org quartz | quartz-scheduler.org terracotta | terracotta.orgThank you !
  • ehcache | ehcache.org quartz | quartz-scheduler.orgterracotta | terracotta.org twitter | @alexsnaps email | alexsnaps@terracotta.org blog | www.codespot.net
  • ehcache | ehcache.org quartz | quartz-scheduler.orgterracotta | terracotta.org twitter | @alexsnaps email | alexsnaps@terracotta.org blog | www.codespot.net