// 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.
= Data Region Configuration

You can set configuration for data regions by using HOCON format. You can configure your data regions to run either RocksDB or B+Tree storage, and fine-tune their performance. A cluster can have several data regions, and you can select the preferred storage type for each.

We recommend to use B+ Tree storage for read-heavy workloads, and RocksDB for write-heavy workloads.


=== RocksDB Region Configuration

Below is the list of properties for link:https://rocksdb.org/[RocksDB,window=_blank] data regions:

[cols="1,1,3",opts="header", stripes=none]
|===
|Property|Default|Description
|name|| The name of the data region.
|size| `256 * 1024 * 1024` | Size of the offheap cache.
|writeBufferSize | `64 * 1024 * 1024` | Size of the write buffer.
|cache| `lru` | The type of the cache to use. Currently only lru is supported.
|numShardBits| `-1` | The number of parts the cache is sharded to.
|===

== Page Memory Region Configuration

Page memory keeps data in B+Tree format. You can set up the following configuration parameters:

[cols="1,1,3",opts="header", stripes=none]
|===
|name|| The name of the data region.
|persistent|`false`| Specifies if the data region is persistent.
|initSize|`256 * 1024 * 1024`| Sets the initial space allocated to the data region.
|maxSize|`256 * 1024 * 1024`| Sets the maximum space that can be allocated to the data region.
|evictionMode|`DISABLED`| Sets the eviction algorithm to use.
|replacementMode|`CLOCK`| Sets the page replacement algorithm.
|evictionThreshold|`0.9`| Configures when the eviction process starts.
|emptyPagesPoolSize|100| The maximum number of empty pages Ignite will try to keep.
|checkpointPageBufSize|0| Sets the size of the page buffer.
|lazyMemoryAllocation|true|If enabled, memory will not be allocated until necessary.
|===

== Configuration Example

The example below shows how to configure two data regions, one using RocksDB storage, and another using page memory:

----
ignite config set --type cluster \
"{
    rocksDb.regions: [{
        name: lsm_region,
        size: 256000000,
        cache: lru
    }],

    pageMemory.regions: [{
        name: btree_region,
        persistent: false,
        maxSize: 256000000,
        lazyMemoryAllocation: true
    }]
}"
----