You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/11 08:42:43 UTC

[GitHub] [flink] liuzhuang2017 commented on a diff in pull request #19413: [FLINK-16078] [docs-zh] Translate "Tuning Checkpoints and Large State…

liuzhuang2017 commented on code in PR #19413:
URL: https://github.com/apache/flink/pull/19413#discussion_r847083524


##########
docs/content.zh/docs/ops/state/large_state_tuning.md:
##########
@@ -166,149 +125,101 @@ public class MyOptionsFactory implements ConfigurableRocksDBOptionsFactory {
 }
 ```
 
-## Capacity Planning
-
-This section discusses how to decide how many resources should be used for a Flink job to run reliably.
-The basic rules of thumb for capacity planning are:
-
-  - Normal operation should have enough capacity to not operate under constant *back pressure*.
-    See [back pressure monitoring]({{< ref "docs/ops/monitoring/back_pressure" >}}) for details on how to check whether the application runs under back pressure.
-
-  - Provision some extra resources on top of the resources needed to run the program back-pressure-free during failure-free time.
-    These resources are needed to "catch up" with the input data that accumulated during the time the application
-    was recovering.
-    How much that should be depends on how long recovery operations usually take (which depends on the size of the state
-    that needs to be loaded into the new TaskManagers on a failover) and how fast the scenario requires failures to recover.
-
-    *Important*: The base line should to be established with checkpointing activated, because checkpointing ties up
-    some amount of resources (such as network bandwidth).
-
-  - Temporary back pressure is usually okay, and an essential part of execution flow control during load spikes,
-    during catch-up phases, or when external systems (that are written to in a sink) exhibit temporary slowdown.
+## 容量规划
+本节讨论如何确定 Flink 作业应该使用多少资源才能可靠地运行。
+容量规划的基本经验法则是:
+  - 正常运行应该有足够的能力在恒定的*反压*下运行。
+    如何检查应用程序是否在反压下运行的详细信息,请参阅 [反压监控]({{< ref "docs/ops/monitoring/back_pressure" >}})。
+  - 在无故障时间内无反压程序运行所需资源之上提供一些额外的资源。
+    需要这些资源来“赶上”在应用程序恢复期间积累的输入数据。
+    这通常取决于恢复操作需要多长时间(这取决于需要在故障转移时加载到新 TaskManager 中的状态大小)以及故障恢复的速度。
+    *重要*:基线应该在开启 checkpointing 的情况下建立,因为 checkpointing 会占用一些资源(例如网络带宽)。
+  - 临时反压通常是可以的,在负载峰值、追赶阶段或外部系统(写入接收器中)出现临时减速时,这是执行流控制的重要部分。
 
-  - Certain operations (like large windows) result in a spiky load for their downstream operators: 
-    In the case of windows, the downstream operators may have little to do while the window is being built,
-    and have a load to do when the windows are emitted.
-    The planning for the downstream parallelism needs to take into account how much the windows emit and how
-    fast such a spike needs to be processed.
+  - 某些操作(如大窗口)会导致其下游算子的负载激增:
+    在窗口的情况下,下游算子可能在构建窗口时几乎无事可做,而在窗口发出时有负载要做。
+    下游并行度的设置需要考虑到窗口输出多少以及需要以多快的速度处理这种峰值。
 
-**Important:** In order to allow for adding resources later, make sure to set the *maximum parallelism* of the
-data stream program to a reasonable number. The maximum parallelism defines how high you can set the programs
-parallelism when re-scaling the program (via a savepoint).
+**重要**:为了方便以后添加资源,请务必将数据流程序的*最大并行度*设置为合理的数字。 最大并行度定义了在重新缩放程序时(通过 savepoint )可以设置程序并行度的高度。
 
-Flink's internal bookkeeping tracks parallel state in the granularity of max-parallelism-many *key groups*.
-Flink's design strives to make it efficient to have a very high value for the maximum parallelism, even if
-executing the program with a low parallelism.
+Flink 的内部以多个*键组(key groups)* 的最大并行度为粒度跟踪并行状态。
+Flink 的设计力求使最大并行度的值达到很高的效率,即使执行程序时并行度很低。
 
-## Compression
-
-Flink offers optional compression (default: off) for all checkpoints and savepoints. Currently, compression always uses 
-the [snappy compression algorithm (version 1.1.4)](https://github.com/xerial/snappy-java) but we are planning to support
-custom compression algorithms in the future. Compression works on the granularity of key-groups in keyed state, i.e.
-each key-group can be decompressed individually, which is important for rescaling. 
-
-Compression can be activated through the `ExecutionConfig`:
+## 压缩
+Flink 为所有 checkpoints 和 savepoints 提供可选的压缩(默认:关闭)。 目前,压缩总是使用 [snappy 压缩算法(版本 1.1.4)](https://github.com/xerial/snappy-java),
+但我们计划在未来支持自定义压缩算法。 压缩作用于 keyed state 下 key-groups 的粒度,即每个 key-groups 可以单独解压缩,这对于重新缩放很重要。
 
+可以通过 `ExecutionConfig` 开启压缩:
 ```java
 ExecutionConfig executionConfig = new ExecutionConfig();
 executionConfig.setUseSnapshotCompression(true);
 ```
 
-<span class="label label-info">Note</span> The compression option has no impact on incremental snapshots, because they are using RocksDB's internal
-format which is always using snappy compression out of the box.
-
-## Task-Local Recovery
+<span class="label label-info">注意</span> 压缩选项对增量快照没有影响,因为它们使用的是 RocksDB 的内部格式,该格式始终使用开箱即用的 snappy 压缩。
 
-### Motivation
+## Task 本地恢复
+### 问题引入
+在 Flink 的 checkpointing 中,每个 task 都会生成其状态快照,然后将其写入分布式存储。 每个 task 通过发送一个描述分布式存储中的位置状态的句柄,向 jobmanager 确认状态的成功写入。
+JobManager 反过来收集所有 tasks 的句柄并将它们捆绑到一个 checkpoint 对象中。
 
-In Flink's checkpointing, each task produces a snapshot of its state that is then written to a distributed store. Each task acknowledges
-a successful write of the state to the job manager by sending a handle that describes the location of the state in the distributed store.
-The job manager, in turn, collects the handles from all tasks and bundles them into a checkpoint object.
+在恢复的情况下,jobmanager 打开最新的 checkpoint 对象并将句柄发送回相应的 tasks,然后可以从分布式存储中恢复它们的状态。 使用分布式存储来存储状态有两个重要的优势。 
+首先,存储是容错的,其次,分布式存储中的所有状态都可以被所有节点访问,并且可以很容易地重新分配(例如,用于重新缩放)。
 
-In case of recovery, the job manager opens the latest checkpoint object and sends the handles back to the corresponding tasks, which can
-then restore their state from the distributed storage. Using a distributed storage to store state has two important advantages. First, the storage
-is fault tolerant and second, all state in the distributed store is accessible to all nodes and can be easily redistributed (e.g. for rescaling).
+但是,使用远程分布式存储也有一个很大的缺点:所有 tasks 都必须通过网络从远程位置读取它们的状态。
+在许多场景中,恢复可能会将失败的 tasks 重新调度到与前一次运行相同的 taskmanager 中(当然也有像机器故障这样的异常),但我们仍然必须读取远程状态。这可能导致*大状态的长时间恢复*,即使在一台机器上只有一个小故障。
 
-However, using a remote distributed store has also one big disadvantage: all tasks must read their state from a remote location, over the network.
-In many scenarios, recovery could reschedule failed tasks to the same task manager as in the previous run (of course there are exceptions like machine
-failures), but we still have to read remote state. This can result in *long recovery time for large states*, even if there was only a small failure on
-a single machine.
+### 解决办法
 
-### Approach
+Task 本地状态恢复正是针对这个恢复时间长的问题,其主要思想如下:对于每个 checkpoint ,每个 task 不仅将 task 状态写入分布式存储中,
+而且还在 task 本地存储(例如本地磁盘或内存)中保存状态快照的次要副本。请注意,快照的主存储仍然必须是分布式存储,因为本地存储不能确保节点故障下的持久性,也不能为其他节点提供重新分发状态的访问,所以这个功能仍然需要主副本。
 
-Task-local state recovery targets exactly this problem of long recovery time and the main idea is the following: for every checkpoint, each task
-does not only write task states to the distributed storage, but also keep *a secondary copy of the state snapshot in a storage that is local to
-the task* (e.g. on local disk or in memory). Notice that the primary store for snapshots must still be the distributed store, because local storage
-does not ensure durability under node failures and also does not provide access for other nodes to redistribute state, this functionality still
-requires the primary copy.
+然而,对于每个 task 可以重新调度到以前的位置进行恢复的 task ,我们可以从次要本地状态副本恢复,并避免远程读取状态的成本。考虑到*许多故障不是节点故障,节点故障通常一次只影响一个或非常少的节点*,
+在恢复过程中,大多数 task 很可能会返回到它们以前的位置,并发现它们的本地状态完好无损。
+这就是 task 本地恢复有效地减少恢复时间的原因。
 
-However, for each task that can be rescheduled to the previous location for recovery, we can restore state from the secondary, local
-copy and avoid the costs of reading the state remotely. Given that *many failures are not node failures and node failures typically only affect one
-or very few nodes at a time*, it is very likely that in a recovery most tasks can return to their previous location and find their local state intact.
-This is what makes local recovery effective in reducing recovery time.
-
-Please note that this can come at some additional costs per checkpoint for creating and storing the secondary local state copy, depending on the
-chosen state backend and checkpointing strategy. For example, in most cases the implementation will simply duplicate the writes to the distributed
-store to a local file.
+请注意,根据所选的 state backend 和 checkpointing 策略,在每个 checkpoint 创建和存储次要本地状态副本时,可能会有一些额外的成本。
+例如,在大多数情况下,实现只是简单地将对分布式存储的写操作复制到本地文件。
 
 {{< img src="/fig/local_recovery.png" class="center" width=50% alt="Illustration of checkpointing with task-local recovery." >}}
+### 主要(分布式存储)和次要(task 本地)状态快照的关系
+Task 本地状态始终被视为次要副本,checkpoint 状态是分布式存储中的主副本。 这对 checkpointing 和恢复期间的本地状态问题有影响:
 
-### Relationship of primary (distributed store) and secondary (task-local) state snapshots
-
-Task-local state is always considered a secondary copy, the ground truth of the checkpoint state is the primary copy in the distributed store. This
-has implications for problems with local state during checkpointing and recovery:
-
-- For checkpointing, the *primary copy must be successful* and a failure to produce the *secondary, local copy will not fail* the checkpoint. A checkpoint
-will fail if the primary copy could not be created, even if the secondary copy was successfully created.
-
-- Only the primary copy is acknowledged and managed by the job manager, secondary copies are owned by task managers and their life cycles can be
-independent from their primary copies. For example, it is possible to retain a history of the 3 latest checkpoints as primary copies and only keep
-the task-local state of the latest checkpoint.
-
-- For recovery, Flink will always *attempt to restore from task-local state first*, if a matching secondary copy is available. If any problem occurs during
-the recovery from the secondary copy, Flink will *transparently retry to recover the task from the primary copy*. Recovery only fails, if primary
-and the (optional) secondary copy failed. In this case, depending on the configuration Flink could still fall back to an older checkpoint.
-
-- It is possible that the task-local copy contains only parts of the full task state (e.g. exception while writing one local file). In this case,
-Flink will first try to recover local parts locally, non-local state is restored from the primary copy. Primary state must always be complete and is
-a *superset of the task-local state*.
+- 对于 checkpointing ,*主副本必须成功*,并且生成*次要本地副本的失败不会使* checkpoint 失败。 如果无法创建主副本,即使已成功创建次要副本,checkpoint 也会失败。
 
-- Task-local state can have a different format than the primary state, they are not required to be byte identical. For example, it could be even possible
-that the task-local state is an in-memory consisting of heap objects, and not stored in any files.
+- 只有主副本由 jobmanager 确认和管理,次要副本属于 taskmanager ,并且它们的生命周期可以独立于它们的主副本。 例如,可以保留 3 个最新 checkpoints 的历史记录作为主副本,并且只保留最新 checkpoint 的 task 本地状态。
 
-- If a task manager is lost, the local state from all its task is lost.
+- 对于恢复,如果匹配的次要副本可用,Flink 将始终*首先尝试从 task 本地状态恢复*。 如果在次要副本恢复过程中出现任何问题,Flink 将*透明地重试从主副本恢复 task*。 仅当主副本和(可选)次要副本失败时,恢复才会失败。 
+  在这种情况下,根据配置,Flink 仍可能回退到旧的 checkpoint 。
+- Task 本地副本可能仅包含完整 task 状态的一部分(例如,写入一个本地文件时出现异常)。 在这种情况下,Flink 会首先尝试在本地恢复本地部分,非本地状态从主副本恢复。 主状态必须始终是完整的,并且是*task 本地状态的超集*。
 
-### Configuring task-local recovery
+- Task 本地状态可以具有与主状态不同的格式,它们不需要相同字节。 例如,task 本地状态甚至可能是在堆对象组成的内存中,而不是存储在任何文件中。
 
-Task-local recovery is *deactivated by default* and can be activated through Flink's configuration with the key `state.backend.local-recovery` as specified
-in `CheckpointingOptions.LOCAL_RECOVERY`. The value for this setting can either be *true* to enable or *false* (default) to disable local recovery.
+- 如果 taskmanager 丢失,则其所有 task 的本地状态都会丢失。
+### 配置 task 本地恢复
 
-Note that [unaligned checkpoints]({{< ref "docs/ops/state/checkpoints" >}}#unaligned-checkpoints) currently do not support task-local recovery.
+Task 本地恢复*默认禁用*,可以通过 Flink 的 CheckpointingOptions.LOCAL_RECOVERY 配置中指定的键 state.backend.local-recovery 来启用。 此设置的值可以是 *true* 以启用或 *false*(默认)以禁用本地恢复。
 
-### Details on task-local recovery for different state backends
+请注意,[unaligned checkpoints]({{< ref "docs/ops/state/checkpoints" >}}#unaligned-checkpoints) 目前不支持 task 本地恢复。
 
-***Limitation**: Currently, task-local recovery only covers keyed state backends. Keyed state is typically by far the largest part of the state. In the near future, we will
-also cover operator state and timers.*
+### 不同 state backends 的 task 本地恢复的详细信息
 
-The following state backends can support task-local recovery.
+***限制**:目前,task 本地恢复仅涵盖 keyed state backends。 Keyed state 通常是该状态的最大部分。 在不久的将来,我们还将介绍算子状态和计时器(timers)。*

Review Comment:
   这里可能没有多星号?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org