1
votes

I have an ignite server running in replicated mode and many clients on same node which has near cache enabled. Now I don't find a significant performance difference when I run client with near cache and without near cache.

My understanding of near cache is that frequently used key and value would be stored on client itself, so there won't be an actual Get() call made to server. please correct me if I am wrong.

Can someone share a working near cache configuration xml.

SERVER CONFIG:
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">
        <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

            <property name="cacheConfiguration">
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="cacheMode" value="LOCAL" />
                                <!-- Enable near cache to cache recently accessed data. -->

                                <!--    <property name="nearConfiguration">

                                    <bean class="org.apache.ignite.configuration.NearCacheConfiguration"/>

                                </property> -->
                    <property name="nearConfiguration">
                    <bean class="org.apache.ignite.configuration.NearCacheConfiguration">
                    </bean>
                    </property>

                </bean>
            </property>
        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <!--
                        Ignite provides several options for automatic discovery that can be used
                        instead os static IP based discovery.
                    -->
                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                    <!-- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> --> 
                             <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">  
                        <property name="addresses">
                            <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <!-- <value>127.0.0.1:48550..48551</value> -->
                                <value>XXX.ZZZ.yyy.36:47500..47501</value>  
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

    </bean>
</beans>


CLIENT CONFIG:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">
        <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

            <property name="cacheConfiguration">
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="cacheMode" value="LOCAL" />
                                <!-- Enable near cache to cache recently accessed data. -->

                                <!--    <property name="nearConfiguration">

                                    <bean class="org.apache.ignite.configuration.NearCacheConfiguration"/>

                                </property> -->
                    <property name="nearConfiguration">
                    <bean class="org.apache.ignite.configuration.NearCacheConfiguration">
                    </bean>
                    </property>

                </bean>
            </property>
        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <!--
                        Ignite provides several options for automatic discovery that can be used
                        instead os static IP based discovery.
                    -->
                    <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
                    <!-- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> --> 
                             <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">  
                        <property name="addresses">
                            <list>
                                <!-- In distributed environment, replace with actual host IP address. -->
                                <!-- <value>127.0.0.1:48550..48551</value> -->
                                <value>XXX.ZZZ.yyy.38:47500..47501</value>  
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>


    </bean>
</beans>
1

1 Answers

1
votes

Yes, near cache improves performance by caching often used entries on node locally, but it doesn't make sense if you run all tests on single machine or JVM. Near cache allows not to go on remote node for data, but in your test everything already works locally.

Also Near cache have no sense for server nodes on REPLICATED or PARTITIONED cache, where number of backups equals or bigger than number of data nodes, because all data set already available for each node locally.

So to get performance boost you need to configure client node to use Near cache, when server nodes work on remote machines. Do not forget to warm up near cache before measuring.

Here is XML snippet for setting Near cache:

...
<bean class="org.apache.ignite.configuration.CacheConfiguration">

       <!-- Your other cache config -->

       <property name="nearConfiguration">
             <bean class="org.apache.ignite.configuration.NearCacheConfiguration"/>
       </property>
</bean>
...