Related Documentation : Integrations : Using Ehcache with JRuby and Rails : Adding Off-Heap Storage under Rails
Adding Off-Heap Storage under Rails
Terracotta BigMemory products provide in-memory data management with a large additional cache located right at the node where your application runs. To use the off-heap storage provided by the Terracotta BigMemory products with your Rails application, follow these steps.
1. Add the ehcache-core-ee.jar to your Rails application lib directory.
2. Modify the ehcache.xml file (in the config directory of your Rails application) by adding the following to each cache where you want to enable off-heap storage:
overflowToOffHeap="true"
maxBytesLocalOffHeap="1G"
When overflowToOffHeap is set to true, it enables the cache to utilize off-heap memory storage to improve performance. Off-heap memory is not subject to Java garbage collection cycles and has a size limit set by the Java property MaxDirectMemorySize.
maxBytesLocalOffHeap sets the amount of off-heap memory available to the cache, and is in effect only if overflowToOffHeap is true. For more information about sizing caches, refer to “Sizing Storage Tiers” in the Configuration Guide for your BigMemory product.
3. Also in the ehcache.xml file, set maxEntriesLocalHeap to at least 100 elements when using an off-heap store to avoid performance degradation. Lower values for maxEntriesLocalHeap trigger a warning to be logged.
4. Now that your application is configured to use off-heap storage, start it with the following commands:
jruby -J-Dcom.tc.productkey.path=/path/to/key -J-XX:MaxDirectMemorySize=2G
-S rails server
This will configure a system property that points to the location of the license key, and it will set the direct memory size. The maxDirectMemorySize must be at least 256M larger than total off-heap memory (the unused portion will still be available for other uses).
For additional configuration options, refer to the Configuration Guide for your BigMemory product.
Note that only serializable cache keys and values can be placed in the off-heap store, similar to DiskStore. Serialization and deserialization take place on putting and getting from the store. This is handled automatically by the jruby-ehcache gem.
Copyright © 2014 Software AG, Darmstadt, Germany.

Product Logo |   Feedback