Apache Ignite: An Introduction

Apache Ignite was born in a company named GridGain, and was later contributed to Apache as community project.

The official documentation reads:

Ignite is an in-memory computing platform that is durable, strongly consistent, and highly available with powerful SQL, key-value and processing APIs

We can think of ignite as an in-memory data grid, though they claim it as an in-memory data fabric. However, I have never been a fan-boy of these jargons! A data fabric is nothing but a combination of data grid, data structures, events, hadoop accelaration, streaming yada yada yada…

  • For the sake of brevity (and my limited experience with this framework) this post is restricted to the use of Ignite only as a data-grid.
  • Ignite is Jcache compliant.
  • It may be run as a cluster on multiple nodes.
  • As long as even one node is running, ignite guarantees data consistencies among nodes.
  • Now, let’s get started.

Download Apache Ignite

Ignite can be downloaded from the official website here. We will be using v2.2.0 binary distribution.

Start Ignite

Ignite may be started from CLI as a server. Or it might also be started from code, as we will be seeing in a moment. Or we may use both. They will automatically detect the cluster nodes themselves and would be added to the quorum.

To start from CLI, run the following command

bin/ignite.sh

However, we would be running only from the code for our purpose. So we don’t even need to download the binary distribution.

Starting from scratch

To start ignite server just by using the ignite library, we add the dependency in pom.xml

<dependency>
   <groupId>org.apache.ignite</groupId>
   <artifactId>ignite-core</artifactId>
   <version>2.2.0</version>
</dependency>

<dependency>
   <groupId>org.apache.ignite</groupId>
   <artifactId>ignite-spring</artifactId>
   <version>2.2.0</version>
</dependency>

This block of code starts the ignite embedded server (It may also be started in client mode, to be passed in configuration).

try(Ignite ignite = Ignition.start("/Users/sjbanerjee/config/example-ignite.xml")) {

  // Data is the POJO having a few setters and getters

  IgniteCache cache = ignite.getOrCreateCache("MyCache");

 

  //To start just as an ignite client

  //Ignition.setClientMode(true);

 

  //Put data in cache

  Data d1 = new Data(1, "d1");

  Data d2 = new Data(2, "d2");

  cache.put(1, d1);

  cache.put(2, d2);

 

  //Do a cache lookup by key

  //Make sure that you override the toString() method for Data class

  System.out.println(cache.get(1));

 

  //We may also broadcast the data on ignite cluster nodes as well

  //The following would print "Hello World" on all the cluster nodes

  ignite.compute().broadcast(()->System.out.println("Hello World"));

}

We may choose to start ignite just as a client, in which case, it won’t store any data by itself, but would connect to the already running ignite cluster. Just be aware, that in that case, a cluster must be already running ignite in server mode.

The xml file that we mentioned above can be found with the apache ignite distribution. The location should be “examples/config/example-ignite.xml”. However, we may choose to provide the configuration dynamically (programmatically) like this:

IgniteConfiguration cfg = new IgniteConfiguration();

 

// Native Persistence configuration.

PersistentStoreConfiguration psCfg = new PersistentStoreConfiguration();

psCfg.setPersistentStorePath("/Users/Sjbanerjee/store");

System.out.println("Persistent Store path : " + psCfg);

 

// Enabling the Persistent Store.

cfg.setPersistentStoreConfiguration(psCfg);

 

//Work directory for write-ahead log

cfg.setWorkDirectory("/Users/SjBanerjee/workspace");

System.out.println("Default work directory location : " + cfg.getWorkDirectory());

 

Ignite ignite = Ignition.start(cfg);

 

// Activating the cluster once all the cluster nodes are up and running.

ignite.active(true);

 

CacheConfiguration<Integer, Data> cacheCfg = new CacheConfiguration<>("Data");

IgniteCache<Integer, Data> cache = ignite.getOrCreateCache(cacheCfg);

This, in my opinion, is the standard way of providing IgniteConfiguration and CacheConfiguration.

Data persistence

Data can either be persisted in memory (by default, if we do not pass any persistent configuration) or in the filesystem as WAL files (binary) like we have set above. We may choose where to store the data. In the above example, we have set the storage location. If we look into the directory, we would see a bunch of binary files under different directories. These are your actual data (ones we have put through cache.put()) (and the index files that we would discuss when we discuss indexing and querying). Remove it and all your data is gone.

We can also query the data in different ways that I will be covering in my next. Keep watching this space.

Reference

Published by Sam Banerjee

I’m an AI and software engineering consultant who helps organizations design and deliver production-ready AI systems. I specialize in translating complex machine learning ideas into scalable, reliable solutions that work under real-world constraints. My focus spans AI architecture, applied ML, and system design, with an emphasis on model behavior, generalization, and operational risk. I work end-to-end—from problem framing and technical strategy to execution and deployment—bringing clarity, rigor, and pragmatism to AI initiatives.

Leave a comment