// 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.
= Persistent Storage

== Overview

Apache Ignite Persistence is designed to provide a quick and responsive persistent storage.
When using the persistent storage, Ignite stores all the data on disk, and loads as much data as it can into RAM for processing.

When persistence is enabled, Ignite stores each partition in a separate file on disk. In addition to data partitions, Ignite stores indexes and metadata.

== Checkpointing

_Checkpointing_ is the process of copying dirty pages from RAM to partition files on disk. A dirty page is a page that was updated in RAM but was not written to the respective partition file.

After a checkpoint is created, all changes are persisted to disk and will be available if the node crashes and is restarted.

Checkpointing is designed to ensure durability of data and recovery in case of a node failure.


This process helps to utilize disk space frugally by keeping pages in the most up-to-date state on disk.


== Configuration Properties

The following table describes some properties of persistent data storage:

[cols="1,1,3",opts="header", stripes=none]
|===
|Property|Default|Description

|name|| The name of the data region.
|size|`256 * 1024 * 1024`| Sets the space allocated to the data region, in bytes.
|replacementMode|`CLOCK`| Sets the page replacement algorithm.
|pageSize|16384| The size of pages in the storage, in bytes.
|===

The table below describes checkpoint configuration:

[cols="1,1,3",opts="header", stripes=none]
|===
|Property|Default|Description
|checkpointDelayMillis|200| Delay before staring a checkpoint after receiving the command.
|checkpointThreads|4| Number of CPU threads dedicated to checkpointing.
|compactionThreads|4| Number of CPU threads dedicated to data compaction.
|interval|180000|Interval between checkpoints in milliseconds.
|intervalDeviation|40| Allowed deviation in checkpoint interval, percent.
|logReadLockThresholdTimeout|0| Threshold for logging long read locks, in milliseconds.
|readLockTimeout|10000| Timeout for checkpoint read lock acquisition, in milliseconds.
|useAsyncFileIoFactory|true| If Ignite uses asynchronous file I/O operations provider.
|===

== Configuration Example

The example below shows how to configure one data region that uses Ignite persistence:

----
ignite config set --type cluster \
"{
    aipersist.regions: [{
        name: btree_persistent_region,
        maxSize: 256000000
    }]
}"
----
