Dmitriy Setrakyan will talk about Pearls of Distributed Programming with Scala and GridGain in Philly’s Scala Meetup, April 16th @ 7pm. Just a few slides but plenty of live coding with some pretty cool and advanced distributed concepts. If you are in or around Philly – stop by.
All information is here.

GridGain is pleased to announce the GA release of GridGain 4.5. This is the last major release in 4.x product line and we’ve been long working on 5.x features and 5.0 is just around the corner.
For all products customers and user running 4.x we highly recommend upgrading to the latest 4.5 release.
New Features And Enhancements
- HyperLocking to minimize locking and serialization overhead for cache transactions under load.
- Risk Analytics benchmark.
- Added support for Custom SQL Functions
GridCacheQueryCustomFunctionExampleto show how to use them.- Full off-heap indexing to
GridH2IndexingSpi. - Topic-based user message exchange.
GridNoopCheckpointSpito remove checkpoint overhead whenever checkpoints are not used.GridNoopSwapSpaceSpito remove swap space overhead whenever it is not used.
Visor New Features and Enhancements
- Telemetry screen in Visor to show overall grid status based on various metrics.
- Dedicated cache tab to show all cache-specific information.
Core Bug Fixes
- Path space issues in
ggstart.batstartup script. - Deadlock with concurrent
evictAll()andunswapAll() - Query iterators are removed but not closed when originating node leaves of fails.
- Restructured all examples to make them easier to use and understand.
Client Connectivity Bug Fixes
- Removed ADD method from client API as it was identical to
putIfAbsentmethod. - Visor Management Bug Fixes
- Visor graph tooltip does not show whole information.
- Visor spits errors (failed to fetch model update) when new node joins and busy with data pre-loading.
Visor Management Bug Fixes
- Visor graph tooltip does not show whole information.
- Visor spits errors (failed to fetch model update) when new node joins and busy with data pre-loading.

GridGain will present at Seattle Scalability and Distributed Systems Meetup in Seattle, MSFT campus. We’ll do one of the coolest presentations we’ve done lately, namely “Pearls of Distributed Programming with GridGain & Scala”. Non-stop live Scala coding with pretty amazing examples of what modern distributed programming should be…
All information can be found here.
Wikibon produced an interesting material (looks like paid by Aerospike, NoSQL database recently emerged by resurrecting failed CitrusLeaf and acquihiring AlchemyDB, which product, of course, was recommended in the end) that compares NoSQL databases based on storing data in flash-based SSD vs. storing data in DRAM.
There are number of factual problems with that paper and I want to point them out.
Note that Wikibon doesn’t mention GridGain in this study (we are not a NoSQL datastore per-se after all) so I don’t have any bone in this game other than annoyance with biased and factually incorrect writing.
“Minimal” Performance Advantage of DRAM vs SSD
The paper starts with a simple statement “The minimal performance disadvantage of flash, relative to main memory…”. Minimal? I’ve seen number of studies where performance difference between SSDs and DRAM range form 100 to 10,000 times. For example, this University of California, Berkeley study claims that SSD bring almost no advantage to the Facebook Hadoop cluster and DRAM pre-caching is the way forward.
Let me provide even shorter explanation. Assuming we are dealing with Java – SSD devices are visible to Java application as typical block devices, and therefore accessed as such. It means that a typical object read from such device involves the same steps as reading this object from a file: hardware I/O subsystem, OS I/O subsystem, OS buffering, Java I/O subsystem & buffering, Java deserialization and induced GC. And… if you read the same object from DRAM – it involves few bytecode instructions – and that’s it.
Native C/C++ apps (like MongoDB) can take a slightly quicker route with memory mapped files (or various other IPC methods) – but the performance increase will not be significant (for obvious reason of needing to read/swap the entire pages vs. single object access pattern in DRAM).
Yet another recent technical explanation of the disadvantages of SSD storage can be found here (talking about Oracle’s “in-memory” strategy).
MongoDB, Cassandra, CouchDB DRAM-based?
Amid all the confusion on this topic it’s no wonder the author got it wrong. Neither MongoDB, Cassandra or CouchDB are in-memory systems. They are disk-based systems with support for memory caching. There’s nothing wrong with that and nothing new – every database developed in the last 25 years naturally provides in-memory caching to augment it’s main disk storage.
The fundamental difference here is that in-memory data systems like GridGain, SAP HAHA, GigaSpaces, GemFire, SqlFire, MemSQL, VoltDB, etc. use DRAM (memory) as the main storage medium and use disk for optional durability and overflow. This focus on RAM-based storage allows to completely re-optimized all main algorithms used in these systems.
For example, ACID implementation in GridGain that provides support for full-featured distributed ACID transactions beats every NoSQL database (EC-based) out there in read and even write performance: there are no single key limitations, no consistency trade offs to make, no application-side MVCC, no user-based conflict resolutions or other crutches – it just works the same way as it works in Oracle or DB2 – but faster.
2TB Cluster for $1.2M :)
If there was on piece in the original paper that was completely made up to fit the predefined narrative it was a price comparison. If the author thinks that 2TB RAM cluster costs $1.2M today – I have not one but two Golden Gate bridges to sell just for him…
Let’s see. A typical Dell/HP/IBM/Cisco blade with 256GB of DRAM will cost below $20K if you just buy on the list prices (Cisco seems to offer the best prices starting at around $15K for 256GB blades). That brings the total cost of 2TB cluster well below $200K (with all network and power equipment included and 100s TBs of disk storage).
Is this more expensive that SSD only cluster? Yes, by 2.5-3x times more expensive. But you are getting dramatic performance increase with the right software that more than justifies that price increase.
Conclusion
2-3x times price difference is nonetheless important and it provides our customers a very clear choice. If price is an issue and high performance is not – there are disk-based systems of wide varieties. If high performance and sub-second response on processing TBs of data is required – the hardware will be proportionally more expensive.
However, with 1GB of DRAM costing less than 10 USD and DRAM prices dropping 30% every 18 months – the era of disks (flash or spinning) is clearly coming to its logical end. It’s normal… it’s a progress and we all need to learn how to adapt.
Has anyone seen tape drives lately?
Overview
GridGain is Java-based middleware for in-memory processing of big data in a distributed environment. It is based on high performance in-memory data platform that integrates fast In-Memory MapReduce implementation with In-Memory Data Grid technology delivering easy to use and easy to scale software. Using GridGain you can process terabytes of data, on 1000s of nodes in under a second.
GridGain typically resides between business, analytics, transactional or BI applications and long term data storage such as RDBMS, ERP or Hadoop HDFS, and provides in-memory data platform for high performance, low latency data storage and processing.
Both, GridGain and Hadoop, are designed for parallel processing of distributed data. However, both products serve very different goals and in most cases are very complementary to each other. Hadoop is mostly geared towards batch-oriented offline processing of historical and analytics payloads where latencies and transactions don’t really matter, while GridGain is meant for real-time in-memory processing of both transactional and non-transactional live data with very low latencies. To better understand where each product really fits, let us compare some main concepts of each product.
GridGain In-Memory Compute Grid vs Hadoop MapReduce
MapReduce is a programming model developed by Google for processing large data sets of data stored on disks. Hadoop MapReduce is an implementation of such model. The model is based on the fact that data in a single file can be distributed across multiple nodes and hence the processing of those files has to be co-located on the same nodes to avoid moving data around. The processing is based on scanning files record by record in parallel on multiple nodes and then reducing the results in parallel on multiple nodes as well. Because of that, standard disk-based MapReduce is good for problem sets which require analyzing every single record in a file and does not fit for cases when direct access to a certain data record is required. Furthermore, due to offline batch orientation of Hadoop it is not suited for low-latency applications.
GridGain In-Memory Compute Grid (IMCG) on the other hand is geared towards in-memory computations and very low latencies. GridGain IMCG has its own implementation of MapReduce which is designed specifically for real-time in-memory processing use cases and is very different from Hadoop one. Its main goal is to split a task into multiple sub-tasks, load balance those sub-tasks among available cluster nodes, execute them in parallel, then aggregate the results from those sub-tasks and return them to user.

Splitting tasks into multiple sub-tasks and assigning them to nodes is the *mapping* step and aggregating of results is *reducing* step. However, there is no concept of mandatory data built in into this design and it can work in the absence of any data at all which makes it a good fit for both, stateless and state-full computations, like traditional HPC. In cases when data is present, GridGain IMCG will also automatically colocate computations with the nodes where the data is to avoid redundant data movement.
It is also worth mentioning, that unlike Hadoop, GridGain IMCG is very well suited for processing of computations which are very short-lived in nature, e.g. below 100 milliseconds and may not require any mapping or reducing.
Here is a simple Java coding example of GridGain IMCG which counts number of letters in a phrase by splitting it into multiple words, assigning each word to a sub-task for parallel remote execution in the map step, and then adding all lengths receives from remote jobs in reduce step.
int letterCount = g.reduce(
BALANCE,
// Mapper
new GridClosure<String, Integer>() {
@Override public Integer apply(String s) {
return s.length();
}
},
Arrays.asList("GridGain Letter Count".split(" ")),
// Reducer
F.sumIntReducer()
));
GridGain In-Memory Data Grid vs Hadoop Distributed File System
Hadoop Distributed File System (HDFS) is designed for storing large amounts of data in files on disk. Just like any file system, the data is mostly stored in textual or binary formats. To find a single record inside an HDFS file requires a file scan. Also, being distributed in nature, to update a single record within a file in HDFS requires copying of a whole file (file in HDFS can only be appended). This makes HDFS well-suited for cases when data is appended at the end of a file, but not well suited for cases when data needs to be located and/or updated in the middle of a file. With indexing technologies, like HBase or Impala, data access becomes somewhat easier because keys can be indexed, but not being able to index into values (secondary indexes) only allow for primitive query execution.
GridGain In-Memory Data Grid (IMDG) on the other hand is an in-memory key-value data store. The roots of IMDGs came from distributed caching, however GridGain IMDG also adds transactions, data partitioning, and SQL querying to cached data. The main difference with HDFS (or Hadoop ecosystem overall) is the ability to transact and update any data directly in real time. This makes GridGain IMDG well suited for working on operational data sets, the data sets that are currently being updated and queried, while HDFS is suited for working on historical data which is constant and will never change.
Unlike a file system, GridGain IMDG works with user domain model by directly caching user application objects. Objects are accessed and updated by key which allows IMDG to work with volatile data which requires direct key-based access.

GridGain IMDG allows for indexing into keys and values (i.e. primary and secondary indices) and supports native SQL for data querying & processing. One of unique features of GridGain IMDG is support for distributed joins which allow to execute complex SQL queries on the data in-memory without limitations.
GridGain and Hadoop Working Together
To summarize:
Hadoop essentially is a Big Data warehouse which is good for batch processing of historic data that never changes, while GridGain, on the other hand, is an In-Memory Data Platform which works with your current operational data set in transactional fashion with very low latencies. Focusing on very different use cases make GridGain and Hadoop very complementary with each other.

Up-Stream Integration
The diagram above shows integration between GridGain and Hadoop. Here we have GridGain In-Memory Compute Grid and Data Grid working directly in real-time with user application by partitioning and caching data within data grid, and executing in-memory computations and SQL queries on it. Every so often, when data becomes historic, it is snapshotted into HDFS where it can be analyzed using Hadoop MapReduce and analytical tools from Hadoop eco-system.
Down-Stream Integration
Another possible way to integrate would be for cases when data is already stored in HDFS but needs to be loaded into IMDG for faster in-memory processing. For cases like that GridGain provides fast loading mechanisms from HDFS into GridGain IMDG where it can be further analyzed using GridGain in-memory Map Reduce and indexed SQL queries.
Conclusion
Integration between an in-memory data platform like GridGain and disk based data platform like Hadoop allows businesses to get valuable insights into the whole data set at once, including volatile operational data set cached in memory, as well as historic data set stored in Hadoop. This essentially eliminates any gaps in processing time caused by Extract-Transfer-Load (ETL) process of copying data from operational system of records, like standard databases, into historic data warehouses like Hadoop. Now data can be analyzed and processed at any point of its lifecycle, from the moment when it gets into the system up until it gets put away into a warehouse.
Dmitriy Setrakyan provided an excellent explanation for In-Memory Data Grid (IMDG) in his blog http://gridgain.blogspot.com/2012/11/in-memory-data-grids-explained.html.
I will try to provide a similar description for In-Memory Compute Grid (IMCG).
PDF version of this article is available.
IMCG – In-Memory Compute Grid
One of the main ideas Dmitriy put forward is the importance of integration between in-memory storage (IMDG) and in-memory processing (IMCG) to be able to build truly scalable applications. Yet – the IMCG and its implementations are seen less frequently than IMDG mainly due to the historical reason described below.
Most vendors to this day concentrate first on storage technology (IMDG, NoSQL, or NewSQL variety). Once the storage product is built – adding any type of non-rudimentary IMCG capability on top of it becomes increasingly difficult, if not impossible overall (we'll see why it is so below). Thus, generally, IMCG capabilities are more fundamental to the overall product and therefore have to be built first or together to be used at the core of the storage side.
It should be no surprise, by the way, that GridGain and Hadoop are still the only products on the market that successfully combine both storage and processing in one product (although very differently), while there are dozens of storage-only projects available (and probably hundreds if you count every NoSQL attempt on GitHub).
Core Concepts
The easiest way to understand IMCGs is through a comparison to IMDGs. While IMDGs focus on distributed in-memory storage and management of large data sets by partitioning this data across available computers in the grid, IMCG concentrate on efficiently executing algorithms (i.e. user's code or instructions) across the same set of computers on the same grid. And that's all there's to it: IMDG is all about storing and managing data in-memory, and IMCG is all about processing and computing across the same data.
When seen from this vantage point – it is pretty clear why tight integration between IMDG and IMCG is so important: they are practically two sides of the same coin – storage and processing, that both coalesce around your data.
Most of the functionality in any IMCG can be split into four individual groups:
- Distributed Deployment & Provisioning
- Distributed Resources Management
- Distributed Execution Models (a.k.a.
IMCG Breadth) - Distributed Execution Services (a.k.a.
IMCG Depth)
1. Distributed Deployment & Provisioning
Historically deployment and provisioning of the user's code onto the grid for execution was one of the core reasons why grid computing in general was considered awkward and cumbersome at best, and downright unusable at worst. From the early products like Globus, Grid Engine, DataSynapse, Platform Computing, and such, to today's Hadoop and most of the NoSQL projects – deploying and re-deploying your changes is a manual step that involves rebuilding all of your libraries, copying them everywhere, and restarting your services. Some systems will do copying & restarting for you (Hadoop) and some will require you to do it manually via some UI-based crutch.
This problem is naturally exacerbated by the fact that IMCGs are a distributed technology to begin with and are routinely used on topologies consisting of dozens if not hundreds of computers. Stopping services, redeploying libraries and re-starting services during developing, CI testing and staging in such topologies becomes a major issue.
GridGain is the first IMCG that simplifies this issue by providing "zero deployment" capabilities. With "zero depoloyment" all necessary JVM classes and resources are loaded on demand. Further, GridGain provides three different modes of peer-to-peer deployment supporting the most complex deployment environments like custom class loaders, WAR/EAR files, etc.
Zero deployment technology enables users to simply bring default GridGain nodes online with these nodes then immediately becoming part of the data and compute grid topology that can store any user objects or perform any user tasks without any need for explicit deployment of user’s classes or resources.
2. Distributed Resources Management
Resource management in distributed systems usually refers to the ability to manage physical devices such as computers, networks, and storage as well as software components like JVM, runtimes and OSes. Specifics of that obviously differ based on whether or not the IMCG is deployed on some kind of managed infrastructure like AWS, how it is DevOps managed, etc.
One of the most important resource management functions of any IMCG is automatic discovery and maintaining consistent topology (i.e. the set of compute nodes). Automatic discovery allows the user to add and remove compute nodes from the IMCG topology at runtime while maintaining zero downtime for the tasks running on the IMCG. Consistent topology ensures that any topology changes (nodes failing and leaving, or new nodes joining) viewed by all compute nodes in the same order and consistently.
GridGain provides the most sophisticated discovery system among any IMCG. Pluggable and user-defined Discovery SPI is at the core of GridGain's ability to provide fully automatic and consistent discovery functionality for GridGain nodes. GridGain is shipped with several out-of-the-box implementations including IP-multicast- and TCP/IP-based implementations with direct support for AWS S3 and Zookeeper.
3. Distributed Execution Models (a.k.a IMCG Breadth)
Support for different distributed execution models is what makes IMCG a compute framework. For clarity let's draw a clear distinction between an execution model (such as MapReduce) and the particular algorithms that can be implemented using this model (i.e. Distributed Search): there is a finite set of execution models but practically an infinite set of possible algorithms.
Generally, the goal of any IMCG (as well as of any compute framework in general) is to support as many different execution models as possible, providing the end-user with the widest set of options on how a particular algorithm can be implemented and ultimately executed in the distributed environment. That's why we often call it IMCG Breadth.
GridGain's IMCG, for a example, provides direct support for the following execution models:
-
MapReduce Processing
GridGain provides general distributed fork-join type of processing optimized for in-memory. More specifically, MapReduce type 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's MapReduce is essentially a distributed computing paradigm that allows you to map your task into smaller jobs based on some key, execute these jobs on Grid nodes, and reduce multiple job results into one task result. This is essentially what GridGain’s MapReduce does. However, the difference of GridGain MapReduce from other MapReduce frameworks, like Hadoop for example, is that GridGain MapReduce is geared towards streaming low-latency in-memory processing.
If Hadoop MapReduce task takes input from disk, produces intermediate results on disk and outputs result onto disk, GridGain does everything Hadoop does in memory – it takes input from memory via direct API calls, produces intermediate results in memory and then creates result in-memory as well. Full in-memory processing allows GridGain provide results in sub-seconds whereas other MapReduce frameworks would take minutes.
-
Streaming Processing & CEP
Streaming processing and corresponding Complex Event Processing (CEP) is a type of processing where input data is not static but rather constantly "streaming" into the system. Unlike other MapReduce frameworks which spawn different external executable processes which work with data from disk files and produce output onto disk files (even when working in streaming mode), GridGain Streaming MapReduce seamlessly works on streaming data directly in-memory.
As the data comes in into the system, user can keep spawning MapReduce tasks and distribute them to any set of remote nodes on which the data is processed in parallel and result is returned back to the caller. The main advantage is that all MapReduce tasks execute directly in-memory and can take input and store results utilizing GridGain in-memory caching, thus providing very low latencies.
-
MPP/RPC Processing
GridGain also provides native support for classic MPP (massively parallel processing) and RPC (Remote Procedure Call) type of processing including direct remote closure execution, unicast/broadcast/reduce execution semantic, shared distribution sessions and many other features.
-
MPI-style Processing
GridGain's high performance distributed messaging provides MPI-style (i.e. message passing based distribution) processing capabilities. Built on proprietary asynchronous IO and world's fastest marshaling algorithm GridGain provides synchronous and asynchronous semantic, distributed events and pub-sub messaging in a distributed environment.
-
AOP/OOP/FP/SQL Integrated Processing
GridGain is the only platform that integrates compute grid capabilities into existing programming paradigms such as AOP, OOP, FP and SQL:
- You can use AOP to annotate your Java or Scala code for automatic MapReduce or MPP execution on the grid.
- You can use both OOP and pure FP APIs for MapReduce/MPP/RPC execution of your code.
- GridGain allows to inject executable closures into SQL execution plan allowing you to inject your own filters, local and remote reducers right into the ANSI SQL.
3. Distributed Execution Services (a.k.a IMCG Depth)
In many respects the distributed execution services is the "meat" around proverbial execution models' "bones". Execution services refer to many dozens of deep IMCG features that support various execution strategies and models including services such as distributed failover, load balancing, collision resolution, etc. – hence the moniker of IMCG Depths.
Many such features are shared between different IMCGs and general compute frameworks – but some are unique to a particular product. Here is a short list of some of the key execution services provided by GridGain's IMCG:
-
Pluggable Failover
Failover management and resulting fault tolerance is a key property of any grid computing infrastructure. Based on its SPI-based architecture GridGain provides totally pluggable failover logic with several popular implementations available out-of-the-box. Unlike other grid computing frameworks GridGain allows to failover the logic and not only the data.
With grid task being the atomic unit of execution on the grid the fully customizable and pluggable failover logic enables developer to choose specific policy much the same way as one would choose concurrency policy in RDBMS transactions.
Moreover, GridGain allows to customize the failover logic for all tasks, for group of tasks or even for every individual task. Using meta-programming techniques the developer can even customize the failover logic for each task execution.
This allows to fine tune how grid task reacts to the failure, for example:
- Fail entire task immediately upon failure of any of its jobs (fail-fast approach)
- Failover failed job to other nodes until topology is exhausted (fail-slow approach) -
Pluggable Topology Resolution
GridGain provides the ability to either directly or automatically select a subset of grid nodes (i.e. a topology) on which MapReduce tasks will be executed. This ability gives tremendous flexibility to the developer in deciding where its task will be executed. The decision can be based on any arbitrary user or system information. For example, time of the day or day of the week, type of task, available resources on the grid, current or average stats from a given node or aggregate from a subset of nodes, network latencies, predefined SLAs, etc.
-
Pluggable Resource Matching
For cases when some grid nodes are more powerful or have more resources than others you can run into scenarios where nodes are not fully utilizes or over-utilized. Under-utilization and over-utilization are both equally bad for a grid – ideally all grid nodes in the grid should be equally utilized. GridGain provides several ways to achieve equal utilization across the grid including, for example:
Weighted Load Balancing
If you know in advance that some nodes are, say, 2 times more powerful than others, you can attach proportional weights to the nodes. For examples, part of your grid nodes would get weight of 1 and the other part would get weight of 2. In this case job distribution will be proportional to node weights and nodes with heavier weight will proportionally get more jobs assigned to them than nodes with lower weights. So nodes with weight 2 will get 2 times more jobs than nodes with weight 1.Adaptive Load Balancing
For cases when nodes are not equal and you don’t know exactly how different they are, GridGain will automatically adapt to differences in load and processing power and will send more jobs to more powerful nodes and less jobs to weaker nodes. GridGain achieves that by listening to various metrics on various nodes and constantly adapting its load balancing policy to the differences in load. -
Pluggable Collision Resolution
Collision resolution allows to regulate how grid jobs get executed when they arrive on a destination node for execution. Its functionality is similar to tasks management via customizable GCD (Great Central Dispatch) on Mac OS X as it allows developer to provide custom job dispatching on a single node. In general a grid node will have multiple jobs arriving to it for execution and potentially multiple jobs that are already executing or waiting for execution on it. There are multiple possible strategies dealing with this situation, like all jobs can proceed in parallel, or jobs can be serialized i.e., or only one job can execute in any given point of time, or only certain number or types of grid jobs can proceed in parallel, etc…
-
Pluggable Early and Late Load Balancing
GridGain provides both early and late load balancing for our Compute Grid that is defined by load balancing and collision resolution SPIs – effectively enabling full customization of the entire load balancing process. Early and late load balancing allows adapting the grid task execution to non-deterministic nature of execution on the grid.
Early load balancing is supported via mapping operation of MapReduce process. The mapping – the process of mapping jobs to nodes in the resolved topology – happens right at the beginning of task execution and therefore it is considered to be an early load balancing
Once jobs are scheduled and have arrived on the remote node for execution they get queued up on the remote node. How long this job will stay in the queue and when it’s going to get executed is controlled by the collision SPI – that effectively defines the late load balancing stage.
One implementation of the load balancing orchestrations provided out-of-the-box is a job stealing algorithm. This detects imbalances at a late stage and sends jobs from busy nodes to the nodes that are considered free right before the actual execution.
Grid and cloud environments are often heterogeneous and non-static, tasks can change their complexity profiles dynamically at runtime and external resources can affect execution of the task at any point. All these factors underscore the need for proactive load balancing during initial mapping operation as well as on destination nodes where jobs can be in waiting queues.
-
Distributed Task Session
A distributed task session is created for every task execution and allows for sharing state between different jobs within the task. Jobs can add, get, and wait for various attributes to be set, which allows grid jobs and tasks to remain connected in order to synchronize their execution with each other and opens a solution to a whole new range of problems.
Imagine for example that you need to compress a very large file (let’s say terabytes in size). To do that in a grid environment you would split such file into multiple sections and assign every section to a remote job for execution. Every job would have to scan its section to look for repetition patterns. Once this scan is done by all jobs in parallel, jobs would need to synchronize their results with their siblings so compression would happen consistently across the whole file. This can be achieved by setting repetition patterns discovered by every job into the session.
-
Redundant Mapping Support
In some cases a guarantee of a timely successful result is a lot more important than executing redundant jobs. In such cases GridGain allows you to spawn off multiple copies of the same job within your MapReduce task to execute in parallel on remote nodes. Whenever the first job completes successfully, the other identical jobs are cancelled and ignored. Such an approach gives a much higher guarantee of successful timely job completion at the expense of redundant executions. Use it whenever your grid is not overloaded and consuming CPU for redundancy is not costly.
-
Node Local Cache
When working in a distributed environment often you need to have a consistent local state per grid node that is reused between various job executions. For example, what if multiple jobs require a database connection pool for their execution – how do they get this connection pool to be initialized once and then reused by all jobs running on the same grid node? Essentially you can think about it as a per-grid-node singleton service, but the idea is not limited to services only, it can be just a regular Java bean that holds some state to be shared by all jobs running on the same grid node.
-
Cron-based Scheduling
In addition to running direct MapReduce tasks on the whole grid or any user-defined portion of the grid (virtual subgrid), you can schedule your tasks to run repetitively as often as you need. GridGain supports Cron-based scheduling syntax for the tasks, so you can schedule your tasks to run using the familiar standard Cron syntax that we are all used to.
-
Partial Asynchronous Reduction
Sometimes when executing MapReduce tasks you don’t need to wait for all the remote jobs to complete in order for your task to complete. A good example would be a simple search. Let’s assume, for example, that you are searching for some pattern from data cached in GridGain data grid on many remote nodes. Once the first job returns with found pattern you don’t need to wait for other jobs to complete as you already found what you were looking for. For cases like this GridGain allows you to reduce (i.e. complete) your task before all the results from remote jobs are received – hence the name “partial asynchronous reduction”. The remaining jobs belonging to your task will be cancelled across the grid in this case.
-
Pluggable Task Checkpoints
Checkpointing a job provides the ability to periodically save its state. This becomes especially useful in combination with fail-over functionality. Imagine a job that may take 5 minute to execute, but after the 4th minute the node on which it was running crashed. The job will be failed over to another node, but it would usually have to be restarted from scratch and would take another 5 minutes. However, if the job was checkpointed every minute, then the most amount of work that could be lost is the last minute of execution and upon failover the job would restart from the last saved checkpoint. GridGain allows you to easily checkpoint jobs to better control overall execution time of your jobs and tasks.
-
Distributed Continuations
Continuations are useful for cases when jobs need to be suspended and their resources need to be released. For example, if you spawn a new task from within a job, it would be wrong to wait for that task completion synchronously because the job thread will remain occupied while waiting, and therefore your grid may run out of threads. The proper approach is to suspend the job so it can be continued later, for example, whenever the newly spawned task completes.
This is where GridGain continuations become really helpful. GridGain allows users to suspend and restart thier jobs at any point. So in our example, where a remote job needs to spawn another task and wait for the result, our job would spawn the task execution and then suspend itself. Then, whenever the new task completes, our job would wake up and resume its execution. Such approach allows for easy task nesting and recursive task execution. It also allows you to have a lot more cross-dependent jobs and tasks in the system than there are available threads.
-
Integration with IMDG
Integration with IMDG based on affinity routing is one of the key concepts behind Compute and Data Grid technologies (whether they are in-memory or disk based). In general, affinity routing allows to co-locate a job and the data set this job needs to process.
The idea is pretty simple: if jobs and data are not co-located, then jobs will arrive on some remote node and will have to fetch the necessary data from yet another node where the data is stored. Once processed this data most likely will have to be discarded (since it’s already stored and backed up elsewhere). This process induces an expensive network trip plus all associated marshaling and demarshalling. At scale – this behavior can bring almost any system to a halt.
Affinity co-location solves this problem by co-locating the job with its necessary data set. We say that there is an affinity between processing (i.e. the job) and the data that this processing requires – and therefore we can route the job based on this affinity to a node where data is stored to avoid unnecessary network trips and extra marshaling and demarshaling. GridGain provides advanced capabilities for affinity co-location: from a simple single-method call to sophisticated APIs supporting complex affinity keys and non-trivial topologies.
Example
The following examples demonstrate a typical stateless computation task of Pi-number calculation on the grid (written in Scala – but can be easily done in Java or Groovy or Clojure as well). This example shows how tremendously simple the implementation can be with GridGain – literally just a dozen lines of code.
Note that this is a full source code – copy'n'paste it, compile it and run it. Note also that it works on one node – and just as well on a thousand nodes in the grid or cloud with no code change – just linearly faster. What is even more interesting is that this application automatically includes all these execution services:
- Auto topology discovery
- Auto load balancing
- Distributed failover
- Collision resolution
- Zero code deployment & provisioning
- Pluggable marshaling & communication
Scala code:
import org.gridgain.scalar._
import scalar._
import scala.math._
object ScalarPiCalculationExample {
private val N = 10000
def main(args: Array[String]) {
scalar {
println("Pi estimate: " +
grid$.spreadReduce(for (i <- 0 until grid$.size()) yield () => calcPi(i * N))(_.sum))
}
}
def calcPi(start: Int): Double =
// Nilakantha algorithm.
((max(start, 1) until (start + N)) map
(i => 4.0 * (2 * (i % 2) - 1) / (2 * i) / (2 * i + 1) / (2 * i + 2)))
.sum + (if (start == 0) 3 else 0)
}

GridGain 4.3.1 service release includes several important bug fixes and host of new optimizations. It is 100% backward compatible and it is highly recommended update for anyone running production systems on 4.x code line.
Details
| Date | November 10th, 2012 |
| Version | 4.3.1e |
| Build | 10112012 |
New Features and Enhancements
- Added remove operation to data loader
- Significantly improved performance of partition to node mapping
- Added
GridSerializationBenchmarkfor comparing performance of Java, Kryo, and GridGain serialization - Added property-based configuration to remote clients
- Optimized concurrency for asynchronous methods in C++ client
- Removed support for Groovy++ DSL Grover
Core Bug Fixes
- Unmarshalling of
SimpleDateFormatfails with NPE - Possible NPE in Indexing Manager when using distributed data structures
- Swap partition iterator skips entries if off-heap iterator is empty
- `GridDataLoader` does not allow to cache primitive arrays
- Excessive memory consumption in indexing SPI
- Add check on startup that
GridOptimizedMarshalleris supported by running JDK version - If ordered message is timed out, other messages for the same topic may not be processed
ScalarPiCalculationExampledoes not provide correct estimate for PI
Client Connectivity Bug Fixes
- Client router with explicit default configuration leads to NPE.
- Repair REST client support to make session token and client ID optional
- Ping does not work properly in C++ client
Visor Management Bug Fixes
- Clear and Compact operations in Visor do not account for node selection
- Move Visor management tasks into a separate thread pool
- Preload dialog in Visor does not show correct number of keys
- GC dialog in Visor waits indefinitely for dead nodes
- Increase tooltip dismiss time in Visor
- Visor log search does not show nodes table correctly on Windows
In-memory processing has been a pretty hot topic lately. Many companies that historically would not have considered using in-memory technology because it was cost prohibitive are now changing their core systems’ architectures to take advantage of the low-latency transaction processing that in-memory technology offers. This is a consequence of the fact that the price of RAM is dropping significantly and rapidly and as a result, it has become economical to load the entire operational dataset into memory with performance improvements of over 1000x faster. In-Memory Compute and Data Grids provide the core capabilities of an in-memory architecture.
The goal of In-Memory Data Grids (IMDG) is to provide extremely high availability of data by keeping it in memory and in highly distributed (i.e. parallelized) fashion. By loading Terabytes of data into memory IMDGs are able to work with most of the Big Data processing requirements today.
At a very high level IMDG is a distributed object store similar in interface to a typical concurrent hash map. You store objects with keys. Unlike traditional systems where keys and values are often limited to byte arrays or strings – with IMDGs you can use any domain object as either value or key. This gives tremendous flexibility by allowing to keep exactly the same object your business logic is dealing with in the Data Grid without the extra step of marshaling and de-marshaling alternative technologies would require. It also simplifies the usage of data grid as you can in most cases interface with distributed data store as with a simple hash map. Being able to work with domain objects directly is one of the main differences between IMDGs and In-Memory Databases (IMDB). With the latter, users still need to perform Object-To-Relational Mapping which typically adds significant performance overhead.
There are also some other features in IMDGs that distinguish them from other products, such as NoSql databases, IMDBs, or NewSql databases. One of the main differences would be truly scalable Data Partitioning across cluster. Essentially IMDGs in their purest form can be viewed as distributed hash maps with every key cached on a particular cluster node – the bigger the cluster, the more data you can cache. The trick to this architecture is to make sure that you collocate your processing with the cluster nodes where data is cached to make sure that all cache operations become local and that there is no (or minimal) data movement within the cluster. In fact, when using well designed IMDGs, there should be absolutely no data movement on stable topologies – the only time when some of the data is moved is when new nodes join in or some existing nodes leave, hence causing some data repartitioning within the cluster.
The picture below shows a classic IMDG with a key set of {k1, k2, k3} where each key belongs to a different node. The external database component is optional. If present, then IMDGs will usually automatically read data from the database or write data to it.

Another distinguishing characteristic of IMDGs is Transactional ACID support. Generally a 2-phase-commit (2PC) protocol is used to ensure data consistency within cluster. Different IMDGs will have different underlying locking mechanisms, but usually more advanced implementations will provide concurrent locking mechanisms (like MVCC – multi-version concurrency control) and reduce network chattiness to a minimum, hence guaranteeing transactional ACID consistency with very high performance.
Data consistency is one of the main differences between IMDGs and NoSQL databases. NoSQL databases are usually designed on top of Eventual Consistency (EC) approach where data is allowed to be inconsistent for a period of time as long as it will become consistent *eventually*. Generally, the writes on EC-based systems are somewhat fast, but reads are slow (or to be more precise, as fast as writes are). Latest IMDGs with an *optimized* 2PC should at least match if not outperform EC-based systems on writes, and be significantly faster on reads. It is interesting to note that the industry has made a full circle moving from a then-slow 2PC approach to the EC approach, and now from EC to an *optimized* 2PC which often is significantly faster.
Different products provide different 2PC optimizations, but generally the purpose of all optimizations is to increase concurrency, minimize network overhead, and reduce the number of locks a transaction requires to complete. As an example, Google’s distributed global database, Spanner, is based on a transactional 2PC approach simply because 2PC provided a faster and more straightforward way to guarantee data consistency and high throughput compared to MapReduce or EC.
Even though IMDGs usually share some common basic functionality, there are many features and implementation details that are different between vendors. When evaluating an IMDG product pay attention to eviction policies, (pre)loading techniques, concurrent repartitioning, memory overhead, etc… Also pay attention to the ability to query data at runtime. Some IMDGs, such as GridGain for example, allow users to query in-memory data using standard SQL, including support for distributed joins, which is pretty rare.
The typical use for IMDGs is to partition data across the cluster and then send collocated computations to the nodes where the data is. Since computations are usually part of Compute Grids and have to be properly deployed, load-balanced, failed-over, or scheduled, the integration between Compute Grids and IMDGs is very important. It is especially beneficial if both In-Memory Compute and Data Grids are part of the same product and utlize the same APIs which removes the need of integration and usually renders utmost performant and reliable systems.

IMDGs (together with Compute Grids) are used throughout a wide spectrum of industries in applications as diverse as Risk Analytics, Trading Systems, Bio Informatics, eCommerce, or Online Gaming. Essentially every project that struggles with scalability and performance can benefit from In-Memory Processing and IMDG architecture.
GridGain is the sponsor and premier exhibitor at Strata + Hadoop World conference in NYC, October 23-25, 2012. Stop by our table and have a chat with GridGain team. Don’t forget to ask them about “1 Billion ACID Updates per Second on 10-nodes Cluster Using GridGain” story!
All information about Strata 2012 conference can be found here.
Welcome to In-Memory Computing…
And, yes, it wasn’t a typo in the title: 1,000,000,000 distributed fully transactional updates per second on 10 nodes cluster costing less than $50K using GridGain’s In-Memory Data Platform.
Most of the time we at GridGain are not at liberty to discuss customers’ benchmark and POC – but I want to share some numbers we’ve recently demonstrated to one of the largest financial institution in the world (under the strict open tender rules). The task was rather simple and isolated – yet the one that presents a challenge to achieve the target performance numbers.
Use Case
Imagine you are building a hypothetical real-time risk analytics system. You have 500 events per second coming into your system and you need to update approximately 10,000,000 positions per each event based on some predefined formula. For obvious performance considerations all data must reside and be processed in memory with possible overflow to disk, when necessary. System should scale linearly up to 100+ of nodes and work on any type of commodity hardware.
What I really like about these requirements is that almost any series financial organization would have projects with similar requirements to these – if not exactly like these. We are all moving towards same-day processing and more and more into the realm of real-time processing regardless of how big the book of business is. And when it comes to risk analytics, fraud protection, or any type of trading – we are seeing these requirements almost on a weekly basis…
Results
Back to this POC. One of our top engineers spent 10 days building this pilot and after few configuration & algorithmic improvements was able to achieve 1 billon ACID updates per second on the target dataset using GridGain 4.3 “Big Data” edition running on 10 nodes cluster consisting of commodity Dell PowerEdge R410 servers with 96GB RAM each.
GridGain 4.3 provides several key features that were necessary in this POC to achieve the performance numbers:
- World’s fastest marshaling algorithm, up to 5x faster than Google Kryo.
- Highly optimized co-located cache mode
- Pluggable & user customizable affinity distribution function
- Affinity-aware group locking
- Pluggable cache store with pre-loading
- Compute and data loaders with back-pressure controlling
There are very few technologies today on the market that can deliver 1,000,000,000 transactions per second on $50K hardware – if any. If you need it today – GridGain 4.3 delivers this performance 100%.


