[ 
https://issues.apache.org/jira/browse/IGNITE-5293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexei Scherbakov updated IGNITE-5293:
--------------------------------------
    Description: 
With increase in number of nodes puts to replicated cache are slowed down 
almost in the same proportion.

Unit test reproducer:
{noformat}
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.ignite.internal.processors.cache.distributed.replicated;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.MemoryConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;

/**
 * Tests replicated cache performance .
 */
public class GridCacheReplicatedTransactionalDegradationTest extends 
GridCommonAbstractTest {
    /** Keys. */
    private static final int KEYS = 100_000;

    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(gridName);

        cfg.setClientMode(gridName.startsWith("client"));

        CacheConfiguration ccfg = new CacheConfiguration();

        ccfg.setCacheMode(CacheMode.REPLICATED);
        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        ccfg.setName("test");

        cfg.setCacheConfiguration(ccfg);

        return cfg;
    }

    /** */
    public void testThroughput() throws Exception {
        try {
            IgniteEx grid0 = startGrid(0);

            Ignite client = startGrid("client");

            IgniteCache<Object, Object> cache = client.getOrCreateCache("test");

            doTest(client, cache);

            startGrid(1);

            doTest(client, cache);

            startGrid(2);

            doTest(client, cache);
        } finally {
            stopAllGrids();
        }
    }

    /**
     * @param client
     * @param cache Cache.
     */
    private void doTest(Ignite client, IgniteCache<Object, Object> cache) {
        long t1 = System.currentTimeMillis();

        for (int i = 0; i < KEYS; i++) {
            try (Transaction tx = 
client.transactions().txStart(TransactionConcurrency.PESSIMISTIC, 
TransactionIsolation.REPEATABLE_READ)) {
                cache.put(i, i);

                tx.commit();
            }
        }

        log.info("TPS: " + Math.round(KEYS / (float)(System.currentTimeMillis() 
- t1) * 1000));
    }
}
{noformat}

My test results are:

1. transactional cache, explicit transaction.
TPS: 2507
TPS: 1660
TPS: 1148

2. atomic cache
TPS: 6416
TPS: 5177
TPS: 4403

3. transactional cache, no explicit transaction
TPS: 4485
TPS: 2289
TPS: 1439



  was:
With increase in number of nodes puts to replicated cache are slowed down 
almost in the same proportion.

Unit test reproducer:
{noformat}
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.ignite.internal.processors.cache.distributed.replicated;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.MemoryConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;

/**
 * Tests replicated cache performance .
 */
public class GridCacheReplicatedTransactionalDegradationTest extends 
GridCommonAbstractTest {
    /** Keys. */
    private static final int KEYS = 100_000;

    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(gridName);

        cfg.setClientMode(gridName.startsWith("client"));

        CacheConfiguration ccfg = new CacheConfiguration();

        ccfg.setCacheMode(CacheMode.REPLICATED);
        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        ccfg.setName("test");

        cfg.setCacheConfiguration(ccfg);

        return cfg;
    }

    /** */
    public void testThroughput() throws Exception {
        try {
            IgniteEx grid0 = startGrid(0);

            Ignite client = startGrid("client");

            IgniteCache<Object, Object> cache = client.getOrCreateCache("test");

            doTest(client, cache);

            startGrid(1);

            doTest(client, cache);

            startGrid(2);

            doTest(client, cache);
        } finally {
            stopAllGrids();
        }
    }

    /**
     * @param client
     * @param cache Cache.
     */
    private void doTest(Ignite client, IgniteCache<Object, Object> cache) {
        long t1 = System.currentTimeMillis();

        for (int i = 0; i < KEYS; i++) {
            try (Transaction tx = 
client.transactions().txStart(TransactionConcurrency.PESSIMISTIC, 
TransactionIsolation.REPEATABLE_READ)) {
                cache.put(i, i);

                tx.commit();
            }
        }

        log.info("TPS: " + Math.round(KEYS / (float)(System.currentTimeMillis() 
- t1) * 1000));
    }
}
{noformat}


> Replicated cache performance degradation.
> -----------------------------------------
>
>                 Key: IGNITE-5293
>                 URL: https://issues.apache.org/jira/browse/IGNITE-5293
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 2.0
>            Reporter: Alexei Scherbakov
>             Fix For: 2.2
>
>
> With increase in number of nodes puts to replicated cache are slowed down 
> almost in the same proportion.
> Unit test reproducer:
> {noformat}
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to You under the Apache License, Version 2.0
>  * (the "License"); you may not use this file except in compliance with
>  * the License.  You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package org.apache.ignite.internal.processors.cache.distributed.replicated;
> import org.apache.ignite.Ignite;
> import org.apache.ignite.IgniteCache;
> import org.apache.ignite.cache.CacheAtomicityMode;
> import org.apache.ignite.cache.CacheMode;
> import org.apache.ignite.cache.CacheWriteSynchronizationMode;
> import org.apache.ignite.configuration.CacheConfiguration;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.configuration.MemoryConfiguration;
> import org.apache.ignite.internal.IgniteEx;
> import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
> import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
> import org.apache.ignite.transactions.Transaction;
> import org.apache.ignite.transactions.TransactionConcurrency;
> import org.apache.ignite.transactions.TransactionIsolation;
> /**
>  * Tests replicated cache performance .
>  */
> public class GridCacheReplicatedTransactionalDegradationTest extends 
> GridCommonAbstractTest {
>     /** Keys. */
>     private static final int KEYS = 100_000;
>     @Override protected IgniteConfiguration getConfiguration(String gridName) 
> throws Exception {
>         IgniteConfiguration cfg = super.getConfiguration(gridName);
>         cfg.setClientMode(gridName.startsWith("client"));
>         CacheConfiguration ccfg = new CacheConfiguration();
>         ccfg.setCacheMode(CacheMode.REPLICATED);
>         ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>         
> ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
>         ccfg.setName("test");
>         cfg.setCacheConfiguration(ccfg);
>         return cfg;
>     }
>     /** */
>     public void testThroughput() throws Exception {
>         try {
>             IgniteEx grid0 = startGrid(0);
>             Ignite client = startGrid("client");
>             IgniteCache<Object, Object> cache = 
> client.getOrCreateCache("test");
>             doTest(client, cache);
>             startGrid(1);
>             doTest(client, cache);
>             startGrid(2);
>             doTest(client, cache);
>         } finally {
>             stopAllGrids();
>         }
>     }
>     /**
>      * @param client
>      * @param cache Cache.
>      */
>     private void doTest(Ignite client, IgniteCache<Object, Object> cache) {
>         long t1 = System.currentTimeMillis();
>         for (int i = 0; i < KEYS; i++) {
>             try (Transaction tx = 
> client.transactions().txStart(TransactionConcurrency.PESSIMISTIC, 
> TransactionIsolation.REPEATABLE_READ)) {
>                 cache.put(i, i);
>                 tx.commit();
>             }
>         }
>         log.info("TPS: " + Math.round(KEYS / 
> (float)(System.currentTimeMillis() - t1) * 1000));
>     }
> }
> {noformat}
> My test results are:
> 1. transactional cache, explicit transaction.
> TPS: 2507
> TPS: 1660
> TPS: 1148
> 2. atomic cache
> TPS: 6416
> TPS: 5177
> TPS: 4403
> 3. transactional cache, no explicit transaction
> TPS: 4485
> TPS: 2289
> TPS: 1439



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to