In-Memory Compute Grid
In-Memory Compute Grid is one of two core technologies that define GridGain foundation. GridGain Systems pioneered the Java-based In-Memory Compute Grid back in 2007 and today it represents the most feature rich and advanced platform for parallel processing and computations for JVM.
Computational grid technology provides means for distribution of processing logic, i.e. parallelization of computations on more than on computer.

More specifically, computational grids or what is frequently called a MapReduce type of processing defines the method of splitting original compute task into multiple sub-tasks, executing these sub-tasks in parallel on any managed infrastructure and aggregating (a.k.a. reducing) results back to one final result.
GridGain provides comprehensive In-Memory Compute Grid and MapReduce capabilities:
- Direct API for split and aggregation
- Pluggable failover, topology and collision resolution
- Distributed task session
- Distributed continuations
- Distribution recursive split
- Support for Streaming MapReduce
- Node-local cache
- AOP-based, OOP/FP-based, synch/asynch execution modes
- Support for direct closure distribution in Java, Scala and Groovy
- Cron-based scheduling
- Direct redundant mapping support
- Zero deployment with P2P class loading
- Partial asynchronous reduction
- Direct support for weighted and adaptive mapping
- State checkpoints for long running tasks
- Early and late load balancing
- Affinity routing with data grid
Example
The following examples demonstrate simple Pi calculations (in Java, Scala and Groovy++) on the grid and how simple the implementation can be with GridGain. Note that this is a full source code - copy it and compile. It works on one node – and just as good on thousands of nodes in the grid or cloud with no code change.
What is even more interesting is that this application automatically includes:
- Auto topology discovery
- Auto load balancing
- Distributed failover
- Collision resolution
- Zero code deployment & provisioning
- Pluggable marshalling & communication
In Scala:
import org.gridgain.scalar._
import scalar._
import org.gridgain.grid.GridClosureCallMode._
import org.gridgain.grid.Grid
object ScalarPiCalculationExample {
private val N = 10000
def main(args: Array[String]) = scalar { g: Grid =>
println("Pi estimate: " +
g.@ calcPi(i * N), _.sum)
}
def calcPi(start: Int): Double =
(start until (start + N)) map
(i => 4.0 * (1 - (i % 2) * 2) / (2 * i + 1)) sum
}
In Groovy++:
import org.gridgain.grid.*
import static org.gridgain.grid.GridClosureCallMode.*
import static org.gridgain.grover.Grover.*
import org.gridgain.grover.categories.*
@Typed
@Use(GroverProjectionCategory)
class GroverPiCalculationExample {
private static int N = 10000
static void main(String[] args) {
grover { Grid g ->
println("Pi estimate: " +
g.reduce$(
SPREAD,
(0.. calcPi(it * N) }
},
{ it.sum() }
)
)
}
}
private static double calcPi(int start) {
(start..
sum + (4.0 * (1 - (i % 2) * 2) / (2 * i + 1))
}
}
}
In Java:
import org.gridgain.grid.*;
import org.gridgain.grid.typedef.*;
import static org.gridgain.grid.GridClosureCallMode.*;
public final class GridPiCalculationExample {
private static final int N = 1000;
private static double calcPi(int start) {
double acc = 0.0;
for (int i = start; i < start + N; i++)
acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1);
return acc;
}
public static void main(String[] args) throws GridException {
G.start();
try {
Grid g = G.grid();
System.out.println("Pi estimate: " +
g.reduce(
SPREAD,
F.yield(F.range(0, g.size()),
new C1() {
@Override public Double apply(Integer i) {
return calcPi(i * N);
}
}
),
F.sumDoubleReducer()
)
);
}
finally {
G.stop(true);
}
}
}
