Wednesday, 02 May 2018
Infinispan 9.2.2.Final and 9.3.0.Alpha1 are out
We have two releases to announce:
first of all is 9.2.2.Final which introduces a second-level cache provider for the upcoming Hibernate ORM 5.3 as well as numerous bugfixes.
Next is 9.3.0.Alpha1 which is the first iteration of our next release. The main item here, aside from bugfixes and preparation work for upcoming features, is the upgrade of our server component to WildFly 12.
Go and get them on our download page
Tags: release final alpha hibernate second level cache provider
Thursday, 01 October 2015
Hibernate Second Level Cache improvements
Infinispan has been implementing Hibernate Second Level Cache for a long time, replacing the previous JBoss Cache implementation with very similar logic. The main aim of the implementation has always been to have very fast reads, keeping the overhead of cache during reads on minimum. This was achieved using local reads in invalidation-mode cache and Infinispan’s putForExternalRead operation, where the request to cache never blocks.
Recently we’ve looked on the implementation again to see whether we can speed it up even more. For a long time you could use only transactional caches to keep the cache in sync with database. However transactions come at some cost so we thought about a way to get around it. And we have found it, through custom interceptors we have managed to do two-phase updates to the cache and now the non-transactional caches are the default configuration. So, if you’re using Hibernate with your own configuration, don’t forget to update that when migrating to Hibernate ORM 5!
With transactions gone, our task was not over. So far entity/collection caching has been implemented for invalidation mode caches, but it’s tempting to consider replication mode, too. For replicated caches, we got rid of a special cache for pending puts (this local cache detects out-of-date reads, keeping the entity cache consistent). Instead, we used different technique where a logical removal from the cache is substituted by replace with a token called tombstone, and updates pre-invalidate the cache in a similar way. This change opened the possibility for non-transactional replicated and distributed caches (transactional mode is not supported). We were pleased to see the results of some benchmark where the high hit ratio in replicated caches has dramatically speeded up all operations.
There is one downside of the current implementation - in replication mode, you should not use eviction, as eviction cannot tell regular entity (which can be evicted) from the tombstone. If tombstone was evicted, there’s a risk of inconsistent reads. So when using replicated caches, you should rely on expiration to keep your cache slender. We hope that eventually we’ll remove this limitation.
All modes described above give us cache without any stale reads. That comes at a cost - each modification (insert, update or removal) requires 2 accesses to the cache (though, sometimes the second access can be asynchronous). Some applications do not require such strict consistency - and that’s where nonstrict-read-write comes to the scene. Here we guarantee that the cache will provide the same result as DB after the modifying transaction commits - between DB commit and transaction commit a stale value can be provided. If you use asynchronous cache, this may be delayed even more but unless the operation fails (e.g. due to locking timeout) the cache will eventually get into a state consistent with DB. This allows us to limit modifications to single cache access per modification.
Note that nonstrict-read-write mode is supported only for versioned entities/collections (that way we can find out which entity is actually newer). Also, you cannot use eviction in nonstrict-read-write mode, for the same reason as in tombstone-based modes. Invalidation cache mode is not supported neither.
If you’ll try out the most recent Hibernate ORM, you’ll find out that Infinispan 7.2.x is used there. This is because ORM 5.0.0.Final was released before Infinispan 8.0.0.Final went out and we can’t change the major version of dependency in micro-release. However, we try to keep Infinispan 8.0.x binary compatible (in parts used by Hibernate), and therefore you can just replace the dependencies on classpath and use the most recent Infinispan, if you prefer to do so.
To sum things up, here is the table of supported configurations:
Concurrency strategy
Cache transactions
Cache mode
Implementation
Eviction
transactional
transactional
invalidation
pending puts
yes
read-write
non-transactional
non-transactional
replicated/distributed
tombstones
no
nonstrict-read-write
versioned entries
There’s also the read-only mode - this can be used instead of both transactional or read-write modes, but at this point it does not offer any further performance gains, since we have to make sure that you don’t see a removed value. Actually, it also does not matter whether you specify transactional or read-write mode; the proper strategy will be picked according to your cache configuration (transactional vs. non-transactional).
We hope that you’ll try these new modes and many consistency fixes included along (you should use Hibernate ORM 5.0.2.Final or later), and tell us about your experience.
Happy caching!
Tags: jpa hibernate second level cache provider
Thursday, 30 May 2013
Introducing JPA Cache Store
Good news everyone - Infinispan 5.3.0 will be introducing a long awaited JPA cache store. This cache store will allow you to store cache entries in the database using proper schema - so that other applications can read the persisted data as well.
In normal use cases, it’s recommended to leverage Infinispan as JPA second level cache and/or query cache. However, if you’d like to use only Infinispan API and you want Infinispan to read from database, or to persist the data into a database with well defined schema, then JPA cache store could be right for you.
Prior to JPA cache store, those who wants to use Infinispan in front of a database to read/write database records would need to write their own cache store implementation. Now, with JPA cache store, users can use Infinispan in front of a database (write-through or write-behind) with ease by using standard JPA mapping and configurations.
To use the cache store is simple - create the standard JPA configuration (persistence.xml) and entity class, and then configure the cache store:
Please see documentations for detailed sample usage and configuration.
Hope you enjoy this new addition!
Ray
Tags: jpa hibernate cache store
Friday, 03 May 2013
The first JUDCon Brazil experience
The first ever JUDCon Brazil was held a couple of weeks back and it was a real blast! Firstly, it offered a great opportunity to meet some members of the JBoss community which have been helping us push JBoss projects forward in this region of the world, such as Hanneli Tavante, Roberto dos Santos Wagner, …etc. It was great sharing ideas, experiences…etc with them and coming up with new ideas!
As mentioned before in the post before the conference, I had two new presentations to deliver, one on JSR-107 specification on JCache API and Infinispan’s implementation, and the other on Hibernate Second Level Cache with Infinispan. The JCache presentation went really well and all the live coding worked as expected.
The second presentation was the busier of the two, with a full room packed with Hibernate/JPA users waiting to hear how to scale up their applications. I got excellent feedback from both presentations and looking forward to giving these presentations in more user groups or conferences.
The presentations are not up yet, but I expect them to be posted online in the next few weeks. In the mean time, here are a couple of temporary links to the PDFs of my presentations:
The big news of the conference was for sure the announcement of JBoss Application Servers' new name: WildFly. We’re actively working with them to make the most out of Infinispan :)
Cheers, Galder
Tags: conference presentations event jsr 107 judcon hibernate second level cache provider
Thursday, 18 April 2013
Infinispan coming to Brazil's JUDCon!!
Infinispan team is coming to São Paulo (Brazil) to present on multiple topics around caching, data grids and NoSQL in Brazil’s first ever JBoss Users & Developers Conference (JUDCon). The event is being held over two days, on 19th and 20th of April.
On the 19th, Manik Surtani and Pete Muir will present on how to supercharge web applications using JBoss Data Grid. Expect a very lively presentation from these very seasoned presenters :)
Another presentation where you’ll be able to see Infinispan in action is in Shekhar Gulati’s "Closed PaaS to Open PaaS : Migrate GAE Applications to OpenShift Using CapeDwarf" and Randall Hauch’s "Elastic Consistent NoSQL Data Storage with ModeShape 3" talk, both on the 19th of April, where Shekhar and Randal will demonstrate JBoss projects using Infinispan heavily.
On 20th of April, I’ll be speaking about scaling up Hibernate/JPA applications with Infinispan second-level cache. Even if the Infinispan caching provider was created almost 4 years ago, this is the first time I’m presenting about it. Really looking forward to that.
Finally, I’ll also give the first ever presentation on Infinispan JCache (JSR-107) API implementation, which will be mostly a live coding session showing different bits about JCache API and the extra capabilities JCache users get from using Infinispan implementation.
Cheers, Galder
Tags: conference data grids event judcon hibernate
Friday, 17 June 2011
So you want JPA-like access to Infinispan?
Back in the early days of Infinispan (since our first public announcement, in fact) we always had it in mind to expose a JPA-like layer to Infinispan. Initially this was as a replacement to the fine-grained replication that JBoss Cache's POJO Cache variant offered, but it grew beyond just a technique to do fine-grained replication on complex object graphs. The fact that it offered a familiar data storage API to Java developers was big. Huge, in fact.
So we realised JPA-on-Infinispan was firmly on the roadmap. The original plan was to implement the entire set of JPA APIs from scratch, but this was a daunting and Herculean task. After much discussion with core Hibernate architects and Infinispan contributors Emmanuel Bernard and Sanne Grinovero, we came to a decision that rather than implementing all this from scratch, it served both Infinispan and the community better to fork Hibernate’s core ORM engine, and replace the relational database mappings with key/value store mappings. And we get to reuse the mature codebase of Hibernate’s session and transaction management, object graph dehydration code, proxies, etc.
And Hibernate OGM (Object-Grid Mapping) was born. After initial experiments and even a large-scale public demo at the JBoss World 2011 Keynote, Emmanuel has officially blogged about the launch of Hibernate OGM. Very exciting times, Infinispan now has a JPA-like layer. :-)
To reiterate a key point from Emmanuel’s blog, Hibernate OGM is still in its infancy. It needs community participation to help it grow up and mature. This is where the Infinispan community should step in; consider Hibernate OGM as Infinispan’s JPA-like layer and get involved. For more details, please read Emmanuel’s announcement.
Enjoy! Manik
Tags: hibernate ogm jpa hibernate API
Tuesday, 07 June 2011
Faster Infinispan-based Second Level Cache coming to a JPA app near you!
Starting with Hibernate 4.0.0.Beta1, Infinispan second level cache interacts with the transaction manager as a JTA Synchronization instead of an XA resource. Based on some testing we’ve done in JBoss AS 7, this has resulted in a huge performance increase thanks to the optimisations the transaction manager can apply to Synchronizations, which work very well when Infinispan is used as a cache rather than as a authoritative data store.
From an Infinispan configuration perspective, nothing needs changing. The Infinispan provider still uses the same base configuration by default. Transactional configuration happens within the cache provider itself and it’s here where the Infinispan is configured with Hibernate’s transaction manager and where Infinispan is configured to participate as a JTA synchronization. This is the default configuration, so from an user perspective, there’s nothing you have to do to take advantage of this new change.
However, you can always switch back to previous behaviour where Infinispan interacted as an XA resource via a dedicated Hibernate property called hibernate.cache.infinispan.use_synchronization
_ _
By default this property is set to true. If you set it false, Infinispan will interact with the transaction manager as an XA resource.
For more detailed information, check the "http://community.jboss.org/docs/DOC-14105[Using Infinispan As JPA Hibernate Second Level Cache Provider]" wiki.
Cheers,
Galder
Tags: transactions jpa synchronization hibernate second level cache provider
Monday, 28 March 2011
Better Hibernate integration!
Hi,
Starting with 5.0 Infinispan’s transaction support was enhanced to allow Synchronization-based enlistment in transactions (v.s. XAResource). A main use case for this is Hibernate’s second level cache: by using Synchronization the transaction manager doesn’t have to write the log on the disk. On the short, better performance!
You can read more about it here. Thanks to Galder Zamarreno, the integration will be released together with HHH-6062.
Cheers,
Mircea
Tags: hibernate
Wednesday, 01 December 2010
Infinispan and JBoss AS 5.x
A lot of people have asked about being able to use Infinispan as a second level cache for Hibernate within JBoss AS 5.x (and its EAP 5.x cousins).
While Infinispan can be used as a Hibernate second level cache with Hibernate 3.5 onwards, Bill deCoste has written a guide to getting Infinispan to work in older versions of Hibernate, specifically with JBoss AS 5.x. Hope you find this useful!
Cheers Manik
Tags: jboss as 5 as5 hibernate second level cache provider
Tuesday, 02 February 2010
Infinispan as a LOCAL cache
While Infinispan has got the distributed, in-memory data grid market firmly it in its sight, there is also another aspect of Infinispan which I feel people would find interesting.
At its heart Infinispan is a highly concurrent, extremely performant data structure than can be distributed, or could be used in a standalone, local mode - as a cache. But why would people use Infinispan over, say, a ConcurrentHashMap? Here are some reasons.
Feature-rich
-
Eviction. Built-in eviction ensures you don’t run out of memory.
-
Write-through and write-behind caching. Going beyond memory and onto disk (or any other pluggable CacheStore) means that your state survives restarts, and preloaded hot caches can be configured.
-
JTA support and XA compliance. Participate in ongoing transactions with any JTA-compliant transaction manager.
-
MVCC-based concurrency. Highly optimized for fast, non-blocking readers.
-
Manageability. Simple JMX or rich GUI management console via JOPR, you have a choice.
-
Not just for the JVM. RESTful API, and upcoming client/server modules speaking Memcached and HotRod protocols help non-JVM platforms use Infinispan.
-
Cluster-ready. Should the need arise.
*Easy to configure, easy to use*
The simplest configuration file containing just
<infinispan />
is enough to get you started, with sensible defaults abound. (More detailed documentation is also available).
All the features above are exposed via an easy-to-use Cache interface, which extends ConcurrentMap and is compatible with many other cache systems. Infinispan even ships with migration tools to help you move off other cache solutions onto Infinispan, whether you need a cache to store data retrieved remotely or simply as a 2nd level cache for Hibernate.
*Performance*
In the process of testing and tuning Infinispan on very large clusters, we have started to put together a benchmarking framework. As a part of this framework, we have the ability to measure cache performance in standalone, local mode. So in the context of this blog post, I’d
like to share some recent performance numbers of Infinispan - a recent snapshot - compared against the latest JBoss Cache release (3.2.2.GA) and EHCache (1.7.2). Some background on the tests:
-
Used a latest snapshot of the CacheBenchFwk
-
Run on a RHEL 5 server with 4 Intel Xeon cores, 4GB of RAM
-
Sun JDK 1.6.0_18, with -Xms1g -Xmx1g
-
Test run on a single node, with 25 concurrent threads, using randomly generated Strings as keys and values and a 1kb payload for each entry, with a 80/20 read/write ratio.
-
Performance measured in transactions per second (higher = better).
In summary, what we have here is that when run in local mode, Infinispan is a high-performance standalone caching engine which offers a rich set of features while still being trivially simple to configure and use.
Enjoy,
Manik
Tags: benchmarks jboss cache hibernate local mode second level cache provider ehcache