Java Ignite性能:如何调整Ignite瘦客户端的缓存写入性能?

Java Ignite性能:如何调整Ignite瘦客户端的缓存写入性能?,java,ignite,Java,Ignite,我正在做一个简单的POC,按照客户机-服务器模式写入大量条目以点燃缓存,测试过程中观察到了这一点 1) 若瘦客户机和服务器位于同一台主机上,则大约需要10分钟才能将100万个条目持久保存到两个缓存中 2) 如果瘦客户机和服务器驻留在不同的主机上,将500个条目保存到两个缓存中大约需要4分钟。这看起来非常糟糕 即使我们考虑了一些网络延迟,我也无法证明案例2中(我们希望采用的实现模式)的延迟是合理的。我想知道这是否与我的缓存配置有关,如下所示 <bean id="grid.cfg" class

我正在做一个简单的POC,按照客户机-服务器模式写入大量条目以点燃缓存,测试过程中观察到了这一点

1) 若瘦客户机和服务器位于同一台主机上,则大约需要10分钟才能将100万个条目持久保存到两个缓存中

2) 如果瘦客户机和服务器驻留在不同的主机上,将500个条目保存到两个缓存中大约需要4分钟。这看起来非常糟糕

即使我们考虑了一些网络延迟,我也无法证明案例2中(我们希望采用的实现模式)的延迟是合理的。我想知道这是否与我的缓存配置有关,如下所示

<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">

    <property name="workDirectory" value="/path/"/>

    <property name="activeOnStart" value="true"/>

    <property name="autoActivationEnabled" value="true"/>

    <property name="deploymentMode" value="SHARED"/>

    <property name="igniteInstanceName" value="test"/>

    <property name="dataStorageConfiguration">
        <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
            <property name="defaultDataRegionConfiguration">
                <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
                    <property name="persistenceEnabled" value="true"/>
                </bean>
            </property>
            <property name="storagePath" value="/path/"/>
        </bean>
    </property>

    <!--
        For better performance set this property to false in case
        peer deployment is not used.
        Default value is true.
    -->
    <property name="peerClassLoadingEnabled" value="false"/>


    <property name="cacheConfiguration">
        <!--
            Specify list of cache configurations here. Any property from
            CacheConfiguration interface can be configured here.
            Note that absolutely all configuration properties are optional.
        -->
        <list>

            <bean parent="cache-template">
                <!-- Cache name is 'testcache1'. -->
                <property name="name" value="testcache1"/>
            </bean>

            <bean parent="cache-template">
                <!-- Cache name is 'testcache2'. -->
                <property name="name" value="testcache2"/>
            </bean>

        </list>
    </property>

</bean>

<!-- Template for all example cache configurations. -->
<bean id="cache-template" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
    <!-- REPLICATED cache mode. -->
    <property name="cacheMode" value="REPLICATED"/>

    <!-- Set synchronous rebalancing (default is asynchronous). -->
    <property name="rebalanceMode" value="SYNC"/>

    <!-- Set to FULL_SYNC for examples, default is PRIMARY_SYNC. -->
    <property name="writeSynchronizationMode" value="FULL_SYNC"/>

    <property name="atomicityMode" value="TRANSACTIONAL"/>
</bean>


瘦客户端代码:

公共类数据网格应用程序{

static DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

private ClientCache<String, String> testcache1;
private ClientCache<String, String> testcache2;



public IgniteDataGridApplication() {
    ClientConfiguration cfg = new ClientConfiguration().setAddresses("serverhostname.net:10800");
    IgniteClient ignite = Ignition.startClient(cfg);
    testcache1 = ignite.cache("testcache1");
    testcache2 = ignite.cache("testcache2");
}

public static void main(String[] args) throws Exception {
    IgniteDataGridApplication igniteDataGridApplication = new IgniteDataGridApplication();
    igniteDataGridApplication.load();
}

private void load() throws Exception {
    List<ThreadProducer> cacheMessages = new ArrayList<>();
    for (int i = 1; i <= 1000000; i++) {
        String testentry = i+"";
        cacheMessages.add(new ThreadProducer("testKey" + i, testentry));

    }
    ExecutorService executorService = Executors.newFixedThreadPool(1000);
    cacheMessages.forEach(executorService::submit);
    executorService.shutdown();
    executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
}


class ThreadProducer implements Runnable {
    private String String;
    private String key;

    public ThreadProducer(String key, String String) {
        this.key = key;
        this.String = String;
    }

    public void run() {
        testcache1.putIfAbsent(key, String);
        testcache2.putIfAbsent(key, String);
        System.out.println("entry :: " + key + " :: " + sdf.format(Calendar.getInstance().getTime()));
    }
}
staticdateformat sdf=newsimpledateformat(“yyyy-MM-dd-HH:MM:ss.SSS”);
私有客户端缓存testcache1;
私有客户端缓存testcache2;
公共数据网格应用程序(){
ClientConfiguration cfg=new ClientConfiguration().setAddresses(“serverhostname.net:10800”);
IgniteClient ignite=Ignition.startClient(cfg);
testcache1=ignite.cache(“testcache1”);
testcache2=ignite.cache(“testcache2”);
}
公共静态void main(字符串[]args)引发异常{
IgniteDataGridApplication IgniteDataGridApplication=新IgniteDataGridApplication();
igniteDataGridApplication.load();
}
私有void load()引发异常{
List cacheMessages=new ArrayList();

对于(int i=1;i尝试使用JFR、JProfiler或您选择的其他探查器分析服务器节点和瘦客户机,以找到减慢操作的瓶颈

确保在这两种情况下,中存在相同数量的节点。如果基线拓扑配置不正确,则可能仅将数据加载到其中一个节点


您可以尝试使用批量加载数据的API方法来提高性能。这是其中一种方法。

请了解性能指南,其中包括持久性优化技术和分析机制: