BigMemory 4.3.8 | Product Documentation | BigMemory Max Configuration Guide | Configuring Storage Tiers | Off-Heap Configuration Examples
 
Off-Heap Configuration Examples
These examples show how to allocate 8GB of machine memory to different stores. It assumes a data set of 7GB - say for a cache of 7M items (each 1kb in size).
Those who want minimal application response-time variance (or minimizing GC pause times), will likely want all the cache to be off-heap. Assuming that 1GB of heap is needed for the rest of the application, they will set their Java config as follows:
java -Xms1G -Xmx1G -XX:maxDirectMemorySize=7G
And their Ehcache config as:
<cache
maxEntriesLocalHeap=100
overflowToOffHeap="true"
maxBytesLocalOffHeap="6G"
... />
Note:
To accommodate server communications layer requirements, the value of maxDirectMemorySize must be greater than the value of maxBytesLocalOffHeap. The exact amount greater depends upon the size of maxBytesLocalOffHeap. The minimum is 256MB, but if you allocate 1GB more to the maxDirectMemorySize, it will certainly be sufficient. The server will only use what it needs and the rest will remain available.
Those who want best possible performance for a hot set of data, while still reducing overall application response time variance, will likely want a combination of on-heap and off-heap. The heap will be used for the hotset, the off-heap for the rest. So, for example if the hot set is 1M items (or 1GB) of the 7GB data. They will set their Java config as follows
java -Xms2G -Xmx2G -XX:maxDirectMemorySize=6G
And their Ehcache config as:
<cache
maxEntriesLocalHeap=1M
overflowToOffHeap="true"
maxBytesLocalOffHeap="5G"
...>
This configuration will compare very favorably against the alternative of keeping the less-hot set in a database (100x slower) or caching on local disk (20x slower).
Where the data set is small and pauses are not a problem, the whole data set can be kept on heap:
<cache
maxEntriesLocalHeap=1M
overflowToOffHeap="false"
...>
Where latency isn't an issue, the disk can be used:
<cache
maxEntriesLocalHeap=1M
<persistence strategy="localTempSwap"/>
...>