blob: 9f958c77278ecbfa2b9e958e11c43aa77b141e5a [file] [log] [blame]
// 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.
= Configuring Data Regions
== Overview
Ignite uses the concept of _data regions_ to control the amount of RAM available to a cache or a group of caches. A data region is a logical extendable area in RAM in which cached data resides. You can control the initial size of the region and the maximum size it can occupy. In addition to the size, data regions control link:persistence/native-persistence[persistence settings] for caches.
By default, there is one data region that can take up to 20% of RAM available to the node, and all caches you create are placed in that region; but you can add as many regions as you want. There are a couple of reasons why you may want to have multiple regions:
* Regions allow you to configure the amount of RAM available to a cache or number of caches.
* Persistence parameters are configured per region. If you want to have both in-memory only caches and the caches that store their content to disk, you need to configure two (or more) data regions with different persistence settings: one for in-memory caches and one for persistent caches.
* Some memory parameters, such as link:memory-configuration/eviction-policies[eviction policies], are configured per data region.
See the following section to learn how to change the parameters of the default data region or configure multiple data regions.
== Configuring Default Data Region
By default, a new cache is added to the default data region. If you want to change the properties of the default data region, you can do so in the data storage configuration.
:xmlFile: code-snippets/xml/data-regions-configuration.xml
:javaFile: {javaCodeDir}/DataRegionConfigurationExample.java
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tags=!*;ignite-config;default;!discovery,indent=0]
----
tab:Java[]
[source,java]
----
include::{javaFile}[tags=!*;ignite-config;default,indent=0]
----
tab:C#/.NET[]
[source,csharp]
----
include::code-snippets/dotnet/MemoryArchitecture.cs[tag=DefaultDataReqion,indent=0]
----
tab:C++[unsupported]
--
== Adding Custom Data Regions
In addition to the default data region, you can add more data regions with custom settings.
In the following example, we configure a data region that can take up to 40 MB and uses the link:memory-configuration/eviction-policies#random-2-lru[Random-2-LRU] eviction policy.
Note that further below in the configuration, we create a cache that resides in the new data region.
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tags=!*;ignite-config;data-region;default;caches;!discovery,indent=0]
----
For the full list of properties, refer to the link:{javadoc_base_url}/org/apache/ignite/configuration/DataStorageConfiguration.html[DataStorageConfiguration] javadoc.
tab:Java[]
[source,java]
----
include::{javaFile}[tags=ignite-config,indent=0]
----
tab:C#/.NET[]
[source,csharp]
----
include::code-snippets/dotnet/MemoryArchitecture.cs[tag=mem,indent=0]
----
tab:C++[unsupported]
--
== Cache Warm-Up Strategy
Ignite does not require you to warm memory up from disk on restarts. As soon as a cluster is inter-connected, your application can query and compute on it. At the same time, the memory warm-up feature is designed for low-latency applications that prefer data being loaded in memory before it can be queried.
Presently, the Ignite warm-up strategy implies loading data into all or specific data regions of Ignite, starting with indexes, until it runs out of free space. It can be configured both for all regions (by default) or for each region separately.
To warm up all data regions, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
:xmlFile: code-snippets/xml/warm-up-strategy.xml
:javaFile: {javaCodeDir}/WarmUpStrategy.java
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tag=warm-all-regions,indent=0]
----
tab:Java[]
[source,java]
----
include::{javaFile}[tag=warm-all-regions,indent=0]
----
tab:C#/.NET[unsupported]
tab:C++[unsupported]
--
To warm up a specific data region, pass the configuration parameter `LoadAllWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tag=warm-specific-region,indent=0]
----
tab:Java[]
[source,java]
----
include::{javaFile}[tag=warm-specific-region,indent=0]
----
tab:C#/.NET[unsupported]
tab:C++[unsupported]
--
To stop the warm-up for all data regions, pass the configuration parameter `NoOpWarmUpConfiguration` to the `DataStorageConfiguration#setDefaultWarmUpConfiguration` as follows:
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tag=disable-all-regions,indent=0]
----
tab:Java[]
[source,java]
----
include::{javaFile}[tag=disable-all-regions,indent=0]
----
tab:C#/.NET[unsupported]
tab:C++[unsupported]
--
To stop the warm-up for a specific data region, pass the configuration parameter `NoOpWarmUpStrategy` to the `DataStorageConfiguration#setWarmUpConfiguration` as follows:
[tabs]
--
tab:XML[]
[source,xml]
----
include::{xmlFile}[tag=disable-specific-region,indent=0]
----
tab:Java[]
[source,java]
----
include::{javaFile}[tag=disable-specific-region,indent=0]
----
tab:C#/.NET[unsupported]
tab:C++[unsupported]
--
You can also stop the cache warm-up by using `control.sh` and JMX.
To stop the warm-up using control.sh:
[tabs]
--
tab:Unix[]
[source,shell,subs="verbatim,quotes"]
----
control.sh --warm-up --stop --yes
----
tab:Windows[]
[source,shell,subs="verbatim,quotes"]
----
control.bat --warm-up --stop --yes
----
--
To stop the warm-up using JMX, use the method:
[source, java]
----
org.apache.ignite.mxbean.WarmUpMXBean#stopWarmUp
----