Tuesday, 2 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.

  • 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.

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.



  1. Very impressive. Great work. Congratulations to you and the team!

  2. Hello.

    I have run CBF tests on Q9400@2.66GHz, 4GB RAM, jdk6u16 64bit, and infinispan gave me 10 million PUT ops. I used default CBF config, with only exception that Number Of Requests parameter was setted up to 1000000.

    Yes, in most cases infinispan behaves better than ehcache and jboss-cache.

    I implemented 3 more plugins for CBF to compare it to some standart hash map implementations: Blocking HashMap, ConcurrentHashMap and Hazelcast cache.

    So, i get some strange results after run. It seems that infinispan (and ehcache, and jboss-cache) put/ops and total duration are very close to speed of standart Blocked Hash Map implementation. Results are even worse than blocked hash map showed up.

    Concurrent Hash map beats 250 million put opts limit, when blocked version only 10.

    I am asking you for a tip... So, there is a question: what is it could be wrong here? Why so big difference, and why infinispan didn't scale well on quad core intel processor (in a local cache mode)? Why infinispan perfomance in local cache mode is like blocked hash map? (i am doing something wrong?)

    I tried various configs. If you need, i can publish source code.

  3. @Ivan, hard to say right now. Why don't you open a user forum discussion in http://community.jboss.org/en/infinispan?view=discussions and you attach/paste:
    - the source code for the 3 implementations
    - the CBF configuration
    - infinispan configuration file

    If it gets too big, simply send me this info to galder at jboss.org

  4. @Ivan, comparing Infinispan against a CHM is inherently unfair. :-) Infinispan adds a lot of additional features and as such would always perform worse than a simple CHM, but this is the tradeoff you have for the additional features (JTA compliance, cache persistence, eviction, etc).

    When you say Blockinh HashMap, I presume you mean a synchronized HashMap?

    Anyway, I recommend you follow Galder's suggestion and discuss this on the Infinispan forums. Perhaps even place a link to your forum post here, so others can follow your trail.


  5. Hi,

    Is the following pattern natively supporting through Infinispan v4.0:
    - a cluster of Infinispan nodes caching data and only doing that,
    - some application clients with a local cache connected to that cluster's central cache

    If so, have you got any performance number ?


  6. @Dominique this will be supported in 4.1.0, using the HotRod protocol to communicate between the "dedicated" cache tier and the application's "near" cache. This will be made transparent by use of a RemoteCacheStore - see ISPN-27.

    No benchmarks as yet, but there will be some soon.

  7. Manik, would be cool if you could break out infinispan a little more, maven wise, so its easier to bring in local-only support. Currently it seems Inifispan core artifact brings in a whole bunch of shit I don't want.

  8. @Bill fair point. Perhaps create a JIRA feature request?

  9. This comment has been removed by the author.

  10. Hi Manik,

    Do you have statistics for clustered environment also(in replication mode) ?

  11. Hi,

    I would be also interested in a benchmark for the clustered environment.

  12. I can't believe synchronized EHCache is just a little bit slower than "highly concurrent" InfiniSpan, "which extends ConcurrentMap" :(

    Is that mistake in performance test scenario?

    Huge mistake....

  13. Hi Manik,

    Can we disable serialization when clustering-mode is LOCAL ? Or would serialization come into picture only when network calls or cache-loaders are involved ?

    I am trying to use Infinispan 5.2.3 in LOCAL mode without any cache-loaders / clustering on single node to get the maximum PUT performance. My application's read/write ratio is almost 50:50.

  14. @by default data is not stored in serialized format
    That can be with :