For everyone — A brigade of chefs around one shared work surface

Imagine a restaurant on a festive evening. With a single cook, everything ends up piling up: orders wait, pots overflow. The solution of large kitchens is the brigade: each chef has their own station, with the ingredients of their post within reach, and all of them work at the same time on the same service. Nobody runs from one end of the kitchen to the other to fetch an ingredient already stored at their neighbor's.

Apache Ignite transposes this idea to computing. When a digital "world" — a simulation, a game, a model — grows too large to fit in a single machine, you split the world's state across several computers, and you send each task to be processed right where the data it needs is already stored. The result behaves, seen from the outside, like one single large machine, but behind the scenes the whole brigade is working in concert.

For the Yokul project, which aims to simulate virtual worlds where countless actors perceive, decide and act in detailed environments, it is a predictable wall: sooner or later, a single computer will no longer suffice. Yokul explores and validates proofs of concept by assembling existing open source building blocks, and Apache Ignite is precisely one of these industrial blocks: it promises to fit an entire world into a shared, distributed memory, without rewriting every behavior.

The full text

A virtual world that grows always ends up hitting the same wall: a JVM, however well fed, is no longer enough. A hundred thousand actors, millions of environment cells, thousands of behaviors evaluated per second — the need changes in nature. It is no longer about "coding well", but about processing in parallel a world state that fits in no machine. Apache Ignite is one of the industrial answers to this problem.

What is Apache Ignite?

Apache Ignite is an open source distributed data and computing platform (Apache Software Foundation). Its central idea: a cluster of machines that behaves — from inside the code — like one single large in-memory data grid, on which you execute computation as close to the data as possible.

Three building blocks combine:

  • The Data Grid: a distributed, partitioned cache, memory-resident, with optional persistence. You store the world's state there, and the cluster takes care of placement, replication and high availability.
  • The Compute Grid: you submit tasks — perception, decision, physics — and the cluster executes them anywhere, ideally on the machine that already hosts the data used.
  • The services on top: SQL queries, continuous event streams (streaming), messaging service, affinity computing.
+──────────────────── cluster Ignite : 3 nœuds ───────────────────────+
|  nœud 1                nœud 2                nœud 3                 |
|  cellules 0..N/3       cellules N/3..2N/3    cellules 2N/3..N       |
|  compute : ouest       compute : centre      compute : est          |
|                                                                     |
|  vue cohérente et partagée de l'état du monde                       |
+─────────────────────────────────────────────────────────────────────+

Why for virtual world simulations?

A simulation is, at bottom, a loop:

while monde_en_cours:
    percevoir()      # les acteurs lisent leur environnement
    décider()        # comportements, IA, mémoire
    agir()           # effets sur l'état du monde
    avancer_le_temps()

The whole challenge of scaling comes down to one question: where to store the state, and where to run décider(), so that all of this unfolds in the right order across hundreds of machines?

Three answers from Ignite to that question:

  • Key-based partitioning: every object of the world (actor, cell, building) is stored under a key and lands on a specific node. The topology of the world dictates the placement, not the infrastructure.
  • Compute co-localization: with compute.affinityRun(key, ...), the task runs directly on the node hosting that key. No copying of the world over the network just to decide whether a cat is asleep.
  • ACID transactions and consistency on demand: useful for the rare operations that require strong consistency (object transfers, dice roll results), while most of the physical updates can tolerate being asynchronous.

An example: simulating a plot of the world

Every actor and every cell is stored in the cache under an explicit key. To advance the simulation of a cell, you ask the cluster to run the update where the cell lives:

Ignite ignite = Ignition.start("yokul-grid.xml");

IgniteCache<CellKey, Cell> cells = ignite.getOrCreateCache("cells");
IgniteCompute compute = ignite.compute();

// Avance la simulation de la cellule, sur le noeud qui l'héberge
for (CellKey key : myCellKeys) {
    compute.affinityRun("cells", key, () -> {
        Cell cell = cells.localPeek(key);            // donnée locale, zéro réseau
        cell.simulateTick(dt);                       // environnement du monde
        for (Actor a : cell.getActorsInCell()) {
            a.getBehavior().simulate(dt, cell);      // moteur XBML local
        }
    });
}

affinityRun guarantees that everything happens on the node that owns the partition. In a geographically structured world, neighboring cells are grouped into the same partitions: an actor crossing a partition boundary is migrated by Ignite, without their behavior changing a single line.

Pitfalls and best practices

The tool is powerful, and — like everything powerful — it rewards humility:

  • Think in keys, not in machines. Partitioning is a modeling choice for the world: the granularity of the keys (cell, quarter, region) determines your performance. Revisit it if the world changes scale.
  • Memory is not infinite. Ignite knows how to evict data out of Java-managed memory (off-heap) and defer disk writes (write-behind); but a fully memory-resident world is costly. Suspending at night, archiving unobserved zones: the simulation itself can learn frugality.
  • The network remains the network. Co-locating computation solves 90% of exchanges, but cross-partition interactions (two actors straddling two boundaries) will never fully eliminate that cost.

In summary

Yokul project need Ignite answer
World state too large for a JVM Partitioned, memory-resident cache
Behaviors evaluated massively Computation sent as close to the data as possible
High availability of the simulator Built-in replication and automatic failover
Observation of flows (weather, crowds) Streaming and continuous SQL queries

Apache Ignite will never make a world interesting: that is the job of behaviors and artists. But it allows an interesting world to keep existing when its population outgrows the capacity of a single machine — and, in a project whose stated ambition is to simulate entire worlds, such elasticity has what it takes to induce vertigo and lucidity at the same time.

See also

  • Message queues — the circulation of events that feeds this computation close to the data
  • Apache Quarkus — the platform that now hosts these distributed services
  • Behavior Model — the behaviors the cluster executes

Article written for the revamp of yokul.org, replacing the page left empty in the 2023 version.