Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Scaling Up Hibernate/JPA Applications with Infi...
Search
Galder Zamarreño
April 20, 2013
Technology
0
210
Scaling Up Hibernate/JPA Applications with Infinispan Second-Level Cache
Galder Zamarreño
April 20, 2013
Tweet
Share
More Decks by Galder Zamarreño
See All by Galder Zamarreño
Principles and Patterns for Streaming Data Analysis
galderz
0
96
Streaming Data Analysis with Kubernetes
galderz
0
2.5k
The Rough Guide to Java RPC Frameworks
galderz
1
7k
Streaming Data Analysis with Kubernetes
galderz
1
410
Streaming Data Workshop @ Codemotion Madrid
galderz
0
1.4k
Streaming Data : ni pierdas el tren, ni esperes en balde
galderz
0
3k
Data grids : descubre qué esconden los datos
galderz
0
3.1k
Streaming Data Workhop @ Devoxx
galderz
0
360
Streaming Data Analysis with Kubernetes
galderz
0
2k
Other Decks in Technology
See All in Technology
複数サービスを支えるマルチテナント型Batch MLプラットフォーム
lycorptech_jp
PRO
1
810
DroidKaigi 2025 Androidエンジニアとしてのキャリア
mhidaka
2
370
スマートファクトリーの第一歩 〜AWSマネージドサービスで 実現する予知保全と生成AI活用まで
ganota
2
270
react-callを使ってダイヤログをいろんなとこで再利用しよう!
shinaps
2
260
20250910_障害注入から効率的復旧へ_カオスエンジニアリング_生成AIで考えるAWS障害対応.pdf
sh_fk2
3
260
株式会社ログラス - 会社説明資料【エンジニア】/ Loglass Engineer
loglass2019
4
65k
これでもう迷わない!Jetpack Composeの書き方実践ガイド
zozotech
PRO
0
1k
Practical Agentic AI in Software Engineering
uzyn
0
110
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
8.8k
Snowflake Intelligenceにはこうやって立ち向かう!クラシルが考えるAI Readyなデータ基盤と活用のためのDataOps
gappy50
0
270
共有と分離 - Compose Multiplatform "本番導入" の設計指針
error96num
2
1k
20250913_JAWS_sysad_kobe
takuyay0ne
2
240
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Faster Mobile Websites
deanohume
309
31k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Designing for humans not robots
tammielis
253
25k
Facilitating Awesome Meetings
lara
55
6.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Balancing Empowerment & Direction
lara
3
620
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
None
Scaling Up Hibernate/JPA Applications with Infinispan Second-Level Cache ! Galder
Zamarreño Senior Software Engineer Red Hat, Inc ! 20th April 2013, São Paulo
Galder Zamarreño • R&D Engineer, Red Hat Inc. • Infinispan
developer • Creator of Infinispan second-level cache provider for Hibernate • Escalante founder and lead • Twitter: @galderz
Agenda • Bottlenecks in Hibernate/JPA applications • Applying caching techniques
sensibly • Distribute caches across multiple nodes • Caching in managed environments
Why do we care?
DB = bottleneck Most Hibernate/JPA applications involve intensive I/O workload
against database
Bottleneck problems Bottlenecks decrease throughput, increase latency... and make users
:(((
We care because we want to make users :))
How do we scale up Hibernate/JPA applications ?
Option 1: $$$ Buy/rent more powerful hardware to host the
DB... who can afford that?
Option 2: Caching Use second-level caching sensibly to reduce burden
on database
Second Level Cache JVM-level, or clustered, cache whose contents can
be shared between different transactions
Lesson 1: Don't apply caching blindly! Always measure first!
Caching cost! Local caches have a cost (memory, GC), clustered
caches add more cost (network, IO)
Demo 1: Measure performance
Lesson 2: Think what you are going to cache!
Think about reads Biggest performance gain comes from caching read-
mostly data
What kind of data? Entities, collections of entities, and query
results can be cached
Entity caching Mark entities cacheable, and define the cache concurrency
strategy
Query caching Speed up execution of repeated queries (w/ same
parameters) by caching their results
Query results validity Cached query results are valid as long
as none of the entity types involved are updated
Demo 2: Query cache in action
Lesson 3: How to select a caching provider
Cache Strategies • Read-only • data never updated • insert/delete
allowed • Read/write • data can be updated • with JBDC transactions or no transactions
Cache Strategies • Nonstrict read/write • data rarely updated •
with JBDC transactions or no transactions • Transactional • data can be updated • for JTA environments
Strategy Support Provider / Strategy read- only nonstrict r/w r/w
transactional Infinispan yes no no yes EhCache yes yes yes yes ConcurretHashMap (testing) yes yes yes no
Lesson 4: Scale up your Hibernate/JPA app going multi-node!
Caches form cluster Infinispan uses JGroups to form a peer-to-peer
cluster, providing discovery, failure detection...etc
Clustered Entities Recommended using invalidation to keep entities consistent accross
cluster (replication can be used too)
Queries / Timestamps Recommended keeping query cache local to each
node, but must replicate update timestamps cache
Demo 3: Clustered second-level cache in action!
Lesson 5: Scaling up JPA in managed environments
JPA Caching simplified Infinispan as default cache provider (with sensible
defaults), and ready to cluster!
shared-cache-mode Persistence unit configuration option that should be set to
ENABLE_SELECTIVE
Demo 4: JPA caching in JBoss AS 7
Summary Q - How do we scale up Hibernate/JPA applications?
Enable second level cache!!
Summary • Don't apply caching blindly! Always measure first! •
Think what you are going to cache! • How to select a caching provider • Scale up your app going multi-node! • Scaling up JPA in managed environments
Questions • http://infinispan.org • http://hibernate.org • http://github.com/galderz/secondlc • https://docs.jboss.org/author/display/ ISPN/Using+Infinispan+as+JPA-Hibernate
+Second+Level+Cache+Provider