简体   繁体   English

如何将Ignite配置为群集Tomcat应用程序的缓存

[英]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. 我正在使用将在Tomcat上运行并使用Apache Ignite作为缓存的Web应用程序。 The application must run in a clustered environment which already has a Zookeeper for other purposes. 该应用程序必须在集群环境中运行,该环境已经具有Zookeeper用于其他目的。

My questions are how should I best configure and fine tune the Ignite nodes? 我的问题是如何最好地配置和微调Ignite节点?

Q1. Q1。 Should I: a) I run each Ignite node inside Tomcat in the same client webapp? 我是否应该: a)我在同一客户端Web应用程序中的Tomcat中运行每个Ignite节点? or b) Have a separate process running Ignite and start Ignite in the webapp as client only. b)有一个单独的进程运行Ignite并仅以客户端身份在Web应用程序中启动Ignite。

Q2. Q2。 How do I limit the amount ofmemory allocated to Ignite? 如何限制分配给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? 如果我在单独的进程中运行,则可以仅在启动时限制该JVM,但是我可以在Tomcat中运行时对资源消耗和垃圾回收崩溃实现类似的限制吗?

My current configuration is in the code excerpt below for a CacheConfiguration set to CacheMode.PARTITIONED . 我的当前配置在下面的代码摘录中,用于将CacheConfiguration设置为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. Q1,您可以使用两种方法。 You can start with having Ignite server node in the same JVM, see if it fits your case. 您可以从在同一JVM中拥有Ignite服务器节点开始,看看是否适合您的情况。

Q2 Starting from Ignite 2.0 it will not use much heap but rather Off-Heap memory to store data. Q2从Ignite 2.0开始,它将不使用太多堆,而是使用堆外内存来存储数据。 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. 然后启用页面驱逐以确保您不会用完该内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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