apache-ignite
157 строк · 6.8 Кб
1// Licensed to the Apache Software Foundation (ASF) under one or more
2// contributor license agreements. See the NOTICE file distributed with
3// this work for additional information regarding copyright ownership.
4// The ASF licenses this file to You under the Apache License, Version 2.0
5// (the "License"); you may not use this file except in compliance with
6// the License. You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15= Data Rebalancing
16
17== Overview
18
19When a new node joins the cluster, some partitions are relocated to the new node so that the data remains distributed equally in the cluster. This process is called _data rebalancing_.
20
21If an existing node permanently leaves the cluster and backups are not configured, you lose the partitions stored on this node.
22When backups are configured, one of the backup copies of the lost partitions becomes a primary partition and the rebalancing process is initiated.
23
24[CAUTION]
25====
26Data rebalancing is triggered by changes in the link:clustering/baseline-topology[Baseline Topology].
27In pure in-memory clusters, the default behavior is to start rebalancing immediately when a node leaves or joins the cluster (the baseline topology changes automatically).
28In clusters with persistence, the baseline topology has to be changed manually (default behavior), or can be changed automatically when link:clustering/baseline-topology#baseline-topology-autoadjustment[automatic baseline adjustment] is enabled.
29====
30
31== Configuring Rebalancing Mode
32
33Ignite supports both synchronous and asynchronous rebalancing.
34In the synchronous mode, any operation on the cache data is blocked until rebalancing is finished.
35In the asynchronous mode, the rebalancing process is done asynchronously.
36You can also disable rebalancing for a particular cache.
37
38To change the rebalancing mode, set one of the following values in the cache configuration.
39
40- `SYNC` — Synchronous rebalancing mode. In this mode, any call to the cache public API is blocked until rebalancing is finished.
41- `ASYNC` — Asynchronous rebalancing mode. Distributed caches are available immediately and load all necessary data from other available cluster nodes in the background.
42- `NONE` — In this mode no rebalancing takes place, which means that caches are either loaded on demand from the persistent storage whenever data is accessed, or populated explicitly.
43
44:javaFile: {javaCodeDir}/RebalancingConfiguration.java
45:xmlFile: code-snippets/xml/rebalancing-config.xml
46
47[tabs]
48--
49tab:XML[]
50[source,xml]
51----
52include::{xmlFile}[tags=!*;ignite-config;mode,indent=0]
53----
54tab:Java[]
55[source,java]
56----
57include::{javaFile}[tags=!*;ignite-config;mode,indent=0]
58----
59tab:C#/.NET[]
60[source,csharp]
61----
62include::code-snippets/dotnet/DataRebalancing.cs[tag=RebalanceMode,indent=0]
63----
64tab:C++[unsupported]
65--
66
67== Configuring Rebalance Thread Pool [[threadpool]]
68
69By default, rebalancing is performed in one thread on each node.
70It means that at each point in time only one thread is used to transfer batches from one node to another, or to process batches coming from the remote node.
71////
72For example, if the cluster has two nodes and a single cache, all the cache's partitions will be re-balanced sequentially, one by one.
73If the cluster has two nodes and two caches, then the caches will be re-balanced in-parallel *TODO*
74////
75
76You can increase the number of threads that are taken from the system thread pool and used for rebalancing.
77A system thread is taken from the pool every time a node needs to send a batch of data to a remote node or needs to process a batch that came from a remote node.
78The thread is relinquished after the batch is processed.
79
80[tabs]
81--
82tab:XML[]
83[source,xml]
84----
85include::{xmlFile}[tags=!*;ignite-config;pool-size,indent=0]
86----
87tab:Java[]
88[source,java]
89----
90include::{javaFile}[tags=!*;ignite-config;pool-size,indent=0]
91----
92tab:C#/.NET[unsupported]
93tab:C++[unsupported]
94--
95
96
97CAUTION: System thread pool is widely used internally by all the cache related operations (put, get, etc.), SQL engine, and other modules. Setting the size of the rebalancing thread pool to a large value may significantly increase rebalancing performance at the cost of decreased throughput.
98
99
100== Rebalance Message Throttling [[throttling]]
101
102When data is transferred from one node to another, the whole data set is split into batches and each batch is sent in a separate message.
103You can configure the batch size and the amount of time the node waits between messages.
104
105
106[tabs]
107--
108tab:XML[]
109[source,xml]
110----
111include::{xmlFile}[tags=!*;ignite-config;throttling,indent=0]
112----
113tab:Java[]
114[source,java]
115----
116include::{javaFile}[tags=!*;ignite-config;throttling,indent=0]
117----
118tab:C#/.NET[]
119[source,csharp]
120----
121include::code-snippets/dotnet/DataRebalancing.cs[tag=RebalanceThrottle,indent=0]
122----
123tab:C++[unsupported]
124--
125
126== Other Properties
127
128The following table lists the properties of `IgniteConfiguration` related to rebalancing:
129
130[CAUTION]
131====
132`rebalanceDelay` and related API's are deprecated and will be removed in the next releases.
133====
134
135[cols="1,4,1",opts="header"]
136|===
137| Property | Description | Default Value
138| `rebalanceThreadPoolSize` |Rebalance thread pool size. Limit of threads used for rebalance. See <<#threadpool>> | min(4, max(1, AVAILABLE_PROC_CNT / 4))
139
140|`rebalanceBatchSize` | The size in bytes of a single rebalance message. The rebalancing algorithm splits the data on every node into multiple batches prior to sending it to other nodes. | 512KB
141
142|`rebalanceBatchesPrefetchCount` | Rebalance batches prefetch count. | 3
143
144|`rebalanceThrottle` | See <<#throttling>>.| 0 (throttling disabled)
145
146| `rebalanceOrder` | The order in which rebalancing should be done. Rebalance order can be set to a non-zero value for caches with SYNC or ASYNC rebalance modes only. Rebalancing for caches with smaller rebalance order is completed first. By default, rebalancing is not ordered. | 0
147
148|`rebalanceTimeout` | Timeout for pending rebalancing messages when they are exchanged between the nodes. | 10 seconds
149
150| `rebalanceDelay` | [Deprecated] A delay in milliseconds before the rebalancing process starts after a node joins or leaves the topology. Rebalancing delay is useful if you plan to restart nodes or start multiple nodes at once or one after another and don't want to repartition and rebalance the data until all nodes are started.
151| 0 (no delay)
152|===
153
154
155== Monitoring Rebalancing Process
156
157You can monitor the link:monitoring-metrics/metrics/new-metrics#caches[rebalancing process for specific caches using JMX].
158