Benchmark of Hazelcast vs. Infinispan, to find the best.

Jboss Infinispan

Infinispan is a distributed in-memory key/value data store with optional schema. The In-Memory Data Grid (IMDG) by Red Hat.

Feature

  • Multi-user System with Apache 2 License
  • Full text search
  • ORM Join Support
  • Corruption Resistant
  • Transactions
    • Concurrency control based on optimistic and pessimistic locks and total order
    • Integration with JTA/JTS
  • Cloud and Virtualization Support
    • EC2, Openshift, Azure, Docker
  • JCache (JSR-107) Provider
  • Cluster Management : JMX
  • Storage : On-Heap (JVM)
  • Integrated Clustering
    • Hibernate L2 Cache
    • WildFly
    • Spring Session
  • Server Protocols
    • Memcached
    • HotRod
    • WebSocket

Hazelcast

Infinispan is a open source In-Memory Data Grid (IMDG) by Hazelcast.

Feature

  • Multi-user System with Apache 2 License
  • Real time analytics
  • Spring Data Support
  • Data Encryption
  • CEP Streaming
  • Distributed Caching (Support Java Concurrency)
  • Integrated Clustering
    • Hibernate L2 Cache
    • Tomcat/Jetty/Grails Clustered Web Sessions
  • JCache (JSR-107) Provider
  • Cloud and Virtualization Support
    • AWS, Azure, Docker, Eureka, Kubernetes, Zookeeper Discovery
  • Storage : On-Heap (JVM)
  • Cluster Management : JMX API
  • Server Protocols
    • Memcached
    • REST
    • Open Binary Client Protocol and Client Implementation Guide

Result

Feature Hazelcast Infinispan
Support for Distributed Hash Table architecture in peer-to-peer mode. YES YES
Support for Fully Replicated architecture in peer-to-peer mode. NO YES
Guarantee that the cache does never become inconsistent when atomic operations are called in peer-to-peer mode, even when cache is misconfigured? YES NO
Elastic deployments in client-server mode (grow automatically with the number of servers) YES YES
Guarantee that the cache does never become inconsistent when atomic operations are called in client-server mode, even when cache is misconfigured? YES NO

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>mapbench</groupId>
    <artifactId>mapbench</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>5.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.hazelcast</groupId>
            <artifactId>hazelcast</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.carrotsearch</groupId>
            <artifactId>junit-benchmarks</artifactId>
            <version>0.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

InfiniTest.java

import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
import com.carrotsearch.junitbenchmarks.BenchmarkRule;
import org.infinispan.manager.DefaultCacheManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import java.util.UUID;

public class InfiniTest {

    @Rule
    public org.junit.rules.TestRule benchmarkRun = new BenchmarkRule();

    private static org.infinispan.Cache<String, String> map;

    @BeforeClass
    public static void beforeClass() throws Exception {
        map = new DefaultCacheManager().getCache("benchmark");
    }

    @AfterClass
    public static void afterClass() throws Exception {
        map.stop();
    }

    @BenchmarkOptions(benchmarkRounds = 1000000, warmupRounds = 100000)
    @Test
    public void testInfinispan() throws Exception {
        map.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    }

}

InfiniTest.testInfinispan: [measured 1000000 out of 1100000 rounds, threads: 1 (sequential)] round: 0.00 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 10, GC.time: 4.30, time.total: 14.48, time.warmup: 1.70, time.bench: 12.78

HazelTest.java

import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
import com.carrotsearch.junitbenchmarks.BenchmarkRule;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

import java.util.Map;
import java.util.UUID;

public class HazelTest {

    @Rule
    public org.junit.rules.TestRule benchmarkRun = new BenchmarkRule();

    private static HazelcastInstance instance;

    private static Map<String, String> map;

    @BeforeClass
    public static void beforeClass() throws Exception {
        Config cfg = new Config();
        instance = Hazelcast.newHazelcastInstance(cfg);
        map = instance.getMap("benchmark");
    }

    @AfterClass
    public static void afterClass() throws Exception {
        instance.getLifecycleService().shutdown();
    }

    @BenchmarkOptions(benchmarkRounds = 1000000, warmupRounds = 100000)
    @Test
    public void testHazelcast() throws Exception {
        map.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    }

}

HazelTest.testHazelcast: [measured 1000000 out of 1100000 rounds, threads: 1 (sequential)] round: 0.00 [+- 0.00], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 11, GC.time: 4.56, time.total: 32.52, time.warmup: 4.26, time.bench: 28.27

Share :
Note : This gist Belong to Mikael Gueck

Subscribe & Social

Subscribe to this blog via RSS.

Recent Posts

Categories

Java 14

Python 2

Wordpress 1

Ops 3

Shared 3

Angular 1

Web 1

Draftblog 1

Popular Tags

Java (14) Python (2) Wordpress (1) Ops (3) Angular (1) Web (1) Draftblog (1)

About

DGStack is web blog by digvijay bhakuni. This blog is about computer programming tips and trick. And some short tutorial and gettings started post about the framework, libriay, api and much more. The blog target mostly open source stuff like java, j2ee, nodeJs, angularJs, spring, struts, mongodb, mean, etc

Disclamer

This website claims no credit for any images posted on this site unless otherwise noted. Images on this blog are copyright to its respectful owners. If there is an image appearing on this blog that belongs to you and do not wish for it appear on this site, please E-mail with a link to said image and it will be promptly removed. And the information is best of my knowledge one can always write comment or mail regarding information is this blog.