简体   繁体   中英

How to configure Ignite as cache for a clustered Tomcat application

I am working in a web application which will run on Tomcat and use Apache Ignite as cache. The application must run in a clustered environment which already has a Zookeeper for other purposes.

My questions are how should I best configure and fine tune the Ignite nodes?

Q1. Should I: a) I run each Ignite node inside Tomcat in the same client webapp? or b) Have a separate process running Ignite and start Ignite in the webapp as client only.

Q2. How do I limit the amount ofmemory allocated to Ignite? If I run in a separate process I can just limit that JVM on start, but can I achieve a similar restriction on resource consumption and garbage collection thrashing running inside Tomcat?

My current configuration is in the code excerpt below for a CacheConfiguration set to CacheMode.PARTITIONED .

private ZookeeperDiscoverySpi getZookeeperDiscoverySpi() {
    ZookeeperDiscoverySpi zkDiscoverySpi = new ZookeeperDiscoverySpi();
    zkDiscoverySpi.setZkConnectionString("127.0.0.1:2181");
    zkDiscoverySpi.setZkRootPath("/apacheIgnite");
    return zkDiscoverySpi;
}

private IgniteConfiguration getDefaultConfiguration(CacheConfiguration cacheCfg) {
    IgniteConfiguration igniteConfig = new IgniteConfiguration();
    igniteConfig.setIgniteInstanceName("IgniteInstanceName");
    igniteConfig.setCacheConfiguration(cacheCfg);
    igniteConfig.setClientMode(clientMode); // set to true for Tomcat webapp, false for Ignite node process
    igniteConfig.setPeerClassLoadingEnabled(false);
    igniteConfig.setMetricsLogFrequency(0);
    igniteConfig.setDiscoverySpi(getZookeeperDiscoverySpi());
    igniteConfig.setMetricsLogFrequency(0);
    return igniteConfig;
}

Q1 you can use both approaches. You can start with having Ignite server node in the same JVM, see if it fits your case.

Q2 Starting from Ignite 2.0 it will not use much heap but rather Off-Heap memory to store data. You can specify memory allowance by changing size of (default) data region in data storage configuration. Then enable page eviction to make sure you do not run out of this memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM