Getting Started with MemoryXtend

In a traditional deployment, all data grid entries are stored in RAM to provide the fastest performance possible. However, while RAM performs better than SSD, it is also more expensive. As SSD gains in popularity, we see new scenarios where storing part of the data in SSD and part in RAM provides great business value. It provides the ability to scale the amount of data you store and handle with a relative small footprint in a cost effective manner, while maintaining high performance where the indexes are always stored in RAM. The MemoryXtend (blobstore) storage model allows an external storage medium (one that does not reside on the JVM heap) to store the Space data.

This topic demonstrates how to implement tiered storage by adding MemoryXtend to a data grid, in order to store part of the data in SSD. For additional information please refer to the MemoryXtend topic.

Adding Tiered Storage to the Data Grid

For instructions on how to deploy the InsightEdge Platform, see InsightEdge in 5 Minutes.

In this deployment, we utilize the available RAM storage to store the most time sensitive (hot) data, and store the less time sensitive (warm) data in SSD. The example uses 3 data types 0, 1 and 2. Data types 0 and 2 are the warm data and should be stored in SSD (which is persistent, and therefore the warm data remains available after the processing unit is redeployed). Data type 1 is the hot data and therefore stored in RAM for faster access.

We deploy a project that has two services (pu.xml files), a feeder that feeds data into the data grid, and a processor service that is responsible to store the data received from the feeder in the correct place. Without the MemoryXtend feature to facilitate tiered storage, all the data resides on RAM. When MemoryXtend is added to the data grid, we can define hot and warm data and where each is stored.

To add MemoryXtend to the data grid modify the processor pu.xml to include the MemoryXtend blobstore, which allows an external storage medium to store the data. In <project path>/src/main/resources/META-INF/spring/pu.xml, do the following:

  1. Add these entries to define the SSD blobstore in the <beans> element:

    xmlns:blob-store="http://www.openspaces.org/schema/rocksdb-blob-store" 
    http://www.openspaces.org/schema/rocksdb-blob-store http://www.openspaces.org/schema/14.0/rocksdb-blob-store/openspaces-rocksdb-blobstore.xsd
  2. Add the blobstore that includes 4 instances with mapping directory to these paths:

    <blob-store:rocksdb-blob-store id="rocksDbBlobstore" paths="[/tmp/memory-xtend-demo/db1,/tmp/memory-xtend-demo/db2,/tmp/memory-xtend-demo/db3,/tmp/memory-xtend-demo/db4]" mapping-dir="/tmp/memory-xtend-demo/mapping"/>
  3. Modify the Space definition to include the blobstore so it stores data persistently in the SSD layer, and define that data type 1 is stored in RAM.

    <os-core:space id="space" url="/./space">
        <os-core:blob-store-data-policy persistent="true" blob-store-handler="rocksDbBlobstore">
            <os-core:blob-store-cache-query class="com.gigaspaces.demo.common.Data" where="type = 1"/>
        </os-core:blob-store-data-policy>
    </os-core:space>

Verifying the Extended Memory

After you configure the tiered storage for your InsightEdge deployment, you should verify that the extended memory has been deployed correctly.

  1. Build the project again.
  2. Deploy the processing unit again and run the query in the Web Management Console:

    select UID, * from com.gigaspaces.demo.common.Data

    Since data was stored persistently in SSD, all data types are fetched.

Additional MemoryXtend Drivers

MemoryXtend supports the following additional storage options for tiered storage, which can be used alone or together with the SSD driver:

  • Persistent Memory (PMEM) - provides performance similar to RAM, but at a cost closer to that of SSD.
  • Off-Heap RAM - stores Space objects in RAM outside the Java heap, which provides better RAM utilization.