Near Cache

classic Classic list List threaded Threaded
10 messages Options
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

Near Cache

Hello,

I am new to Apache Ignite and exploring many cool features. My application requires Ignite to run as embedded and use off-heap memory to cache data. That means each application node is Server with off-heap storage capability.

Can you please post example XML configuration for Near cache?
I used below and caching seems to work, but not sure if it has correctly configured it as Near cache. Tried MBEAN and visor console, but no hints. Can you please comment on below configuration and way to ensure it is configured correctly?

<property name="cacheConfiguration">
        <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                        <property name="name" value="RECORDS"/>
                        <property name="cacheMode" value="PARTITIONED"/>
                        <property name="memoryMode" value="OFFHEAP_TIERED"/>
                        <property name="swapEnabled" value="false"/>
                        <property name="offHeapMaxMemory" value="#{5 * 1024L * 1024L * 1024L}"/>
                        <property name="nearConfiguration"> 
                                <bean class="org.apache.ignite.configuration.NearCacheConfiguration"/> 
                        </property> 
                </bean>
        </list>
</property>

How can I configure off-heap 5GB and near cache for 10000 entries?  I am unable to configure eviction policy for near cache in XML.

Thanks a lot.
-Sam
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

Hi Sam,

How many nodes do you have? Is it a server node that is embedded in the application? If yes, what is the reason for having a near cache?

-Val
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

This post was updated on .
Thank you for quick response. Here are more details and my view point of usage -

From java application we are starting Ignite instance using "Ignition.start(configFilename)".
We are keeping "clienMode" default. ( clientMode property not defined in XML configuration and java code also not using Ignition.setClientMode() )
Typically we run 2 to 4 remote instances of application.
Total cache size (multiple caches) can grow beyond 10s of GB, so off-heap. We have few caches with READ ONLY data and for those we would like to have Near cache.

With Near cache configuration we are looking at below benefits -
1. Avoid Serialization/de-serialization for frequently used objects
2. Owner node for cached entry can be Node2, but Node 1 or all nodes are frequently using it, so avoid network hop. (Node2 holds data in off-heap partitioned cache, at the same time it is available locally with node1 or all nodes in near cache after first access)
3. Want to keep limited entries in near cache to avoid huge heap size.

Thanks,
--Sam
vdpyatkov vdpyatkov
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

Also you can read the article: [1].


On Sat, Aug 13, 2016 at 4:19 AM, [hidden email] <[hidden email]> wrote:
Thank you for quick response. Here are mode details and my view point of
usage -

From java application we are starting Ignite instance using
"Ignition.start(configFilename)".
We are keeping "clienMode" default. ( clientMode property not defined in XML
configuration and java code also not using Ignition.setClientMode() )
Typically we run 2 to 4 remote instances of application.
Total cache size (multiple caches) can grow beyond 10s of GB, so off-heap.
We have few caches with READ ONLY data and for those we would like to have
Near cache.

With Near cache configuration we are looking at below benefits -
1. Avoid Serialization/de-serialization for frequently used objects
2. Owner node for cached entry can be Node2, but Node 1 or all nodes are
frequently using it, so avoid network hop. (Node2 holds data in off-heap
partitioned cache, at the same time it is available locally with node1 or
all nodes in near cache after first access)
3. Want to keep limited entries in near cache to avoid huge heap size.

Thanks,
--Sambhav




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Near-Cache-tp7033p7035.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.



--
Vladislav Pyatkov
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

In reply to this post by javastuff.sam@gmail.com
Sam,

NearCacheConfiguration has nearEvictionPolicy property that you can use:

<property name="nearConfiguration">
    <bean class="org.apache.ignite.configuration.NearCacheConfiguration">
        <property name="nearEvictionPolicy">
            <bean class="org.apache.ignite.cache.eviction.lru.LruEvictionPolicy">
                <property name="maxSize" value="10000"/>
            </bean>
        </property>
    </bean>
</property>

-Val
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

How can I monitor NEAR cache? MBEAN and Visor not helping, is there another way?

vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

I don't there is something available out of the box. However, you can create a small app that will get the contents of near cache using IgniteCache API:

cache.localEntries(CachePeekMode.NEAR);

-Val
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

Thanks. I know it won't be a good way to approach it, Is there any class instance I can search for in heapdump to count number of entries or heap space used by near cache?  
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

You can search for GridNearCacheEntry or GridNearOffHeapCacheEntry, but that sounds like a very complicated approach indeed :)

-Val
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Near Cache

Thanks. This should help analyzing OOM with incorrect sizing configuration.