Apache Flink:状态后端在哪里保存状态?
Apache Flink: Where do State Backends keep the state?
我得到以下声明:
"Depending on your state backend, Flink can also manage the state for the application, meaning Flink deals with the memory management (possibly spilling to disk if necessary) to allow applications to hold very large state."
https://ci.apache.org/projects/flink/flink-docs-master/dev/stream/state/state_backends.html
这是否意味着只有当状态后端配置为 RocksDBStateBackend
时,状态才会保留在内存中,并可能在必要时溢出到磁盘?
但是,如果配置为 MemoryStateBackend
或 FsStateBackend
,状态只保留在内存中,永远不会溢出到磁盘。
是的,总的来说你是对的。只有 RocksDBStateBackend
才会有数据溢出到磁盘。
在 MemoryStateBackend
和 FsStateBackend
的情况下,状态始终保存在 TaskManager 内存中,因此必须适合那里。这两个后端之间的区别在于它们检查点数据的方式。
在 MemoryStateBackend
的情况下,检查点数据被发送到 JobManager 并保存在内存中。
FsStateBackend
将数据存储在文件系统中的检查点上,并仅将少量元数据发送到 JobManager(或在 HA 场景中存储在元数据文件夹中)
因此,对于任何生产用例,强烈建议使用 RocksDBStateBackend
。您可以找到更深入的信息 here.
我得到以下声明:
"Depending on your state backend, Flink can also manage the state for the application, meaning Flink deals with the memory management (possibly spilling to disk if necessary) to allow applications to hold very large state."
https://ci.apache.org/projects/flink/flink-docs-master/dev/stream/state/state_backends.html
这是否意味着只有当状态后端配置为 RocksDBStateBackend
时,状态才会保留在内存中,并可能在必要时溢出到磁盘?
但是,如果配置为 MemoryStateBackend
或 FsStateBackend
,状态只保留在内存中,永远不会溢出到磁盘。
是的,总的来说你是对的。只有 RocksDBStateBackend
才会有数据溢出到磁盘。
在 MemoryStateBackend
和 FsStateBackend
的情况下,状态始终保存在 TaskManager 内存中,因此必须适合那里。这两个后端之间的区别在于它们检查点数据的方式。
在
MemoryStateBackend
的情况下,检查点数据被发送到 JobManager 并保存在内存中。FsStateBackend
将数据存储在文件系统中的检查点上,并仅将少量元数据发送到 JobManager(或在 HA 场景中存储在元数据文件夹中)
因此,对于任何生产用例,强烈建议使用 RocksDBStateBackend
。您可以找到更深入的信息 here.