Infinispan performance tweaks
Join the DZone community and get the full member experience.
Join For Free This article is a follow up to Getting started: Infinispan as remote cache cluster
Out of the box Infinispan configuration works great for low to medium number of GET/PUT operations. But in distributed mode and for heavy GET/PUT operations, you may frequently see locking failures like this one:
2013-03-22 00:14:20,033 [DEBUG] org.infinispan.server.hotrod.HotRodDecoder HotRodClientMaster-63 - Exception caught org.infinispan.server.hotrod.HotRodException: org.infinispan.util.concurrent.TimeoutException: Unable to acquire lock after [10 seconds] on key [ByteArrayKey{data=ByteArray{size=18, hashCode=48079ac7, array=0x033e0f3134354065..}}] for requestor [Thread[HotRodClientMaster-63,5,main]]! Lock held by [(another thread)] at org.infinispan.server.hotrod.HotRodDecoder.createServerException(HotRodDecoder.scala:214) at org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:75) at org.infinispan.server.core.AbstractProtocolDecoder.decode(AbstractProtocolDecoder.scala:45)
Infinispan uses locking to maintain cache consistency. Optimizing locking settings can help improve overall performance. Here are some configuration tips to avoid locking issues and improve concurrency:
<default> <locking concurrencylevel="1000" isolationlevel="READ_COMMITTED" lockacquisitiontimeout="500" uselockstriping="false"> <jmxstatistics enabled="true" /> <!-- Configure a asynchronous distributed cache --> <clustering mode="distribution"> <async/> <hash numowners="2"></clustering> </locking> </default>Explanation:
- Concurrency level: Adjust this value according to the number of concurrent threads interacting with Infinispan.
- lockAcquisitionTimeout: Maximum time to attempt a particular lock acquisition. Set this based on your application needs.
- useLockStriping: If true, a pool of shared locks is maintained for all entries that need to be locked. Otherwise, a lock is created per entry in the cache. Lock striping helps control memory footprint but may reduce concurrency in the system.
Published at DZone with permission of Nishant Chandra, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Getting Started With the YugabyteDB Managed REST API
-
10 Traits That Separate the Best Devs From the Crowd
-
Integrate Cucumber in Playwright With Java
-
Five Java Books Beginners and Professionals Should Read
Comments