How to store checkpoint into remote RocksDB in Apache Flink

人走茶凉 提交于 2020-06-17 09:07:07

问题


I know that there are three kinds of state backends in Apache Flink: MemoryStateBackend, FsStateBackend and RocksDBStateBackend.

MemoryStateBackend stores the checkpoints into local RAM, FsStateBackend stores the checkpoints into local FileSystem, and RocksDBStateBackend stores the checkpoints into RocksDB. I have some questions about the RocksDBStateBackend.

As my understanding, the mechanism of RocksDBStateBackend has been embedded into Apache Flink. The rocksDB is a kind of key-value DB. So If I'm right, it means that Flink will store all checkpoints into the embedded rocksDB, which uses the local disk.

If so, I think the disk could be exhausted in some cases because of the checkpoints stored into the rocksDB. Now I'm thinking if it is possible to configure a remote rocksDB to store these checkpoints? If it is possible, should we worry about the remote rocksDB crashing? If the remote rocksDB crashes, the jobs of Flink can not continue working, right?


回答1:


There is no option to use an external or remote RocksDB with Apache Flink. RocksDB is an embedded key-value store with a local instance in each task manager.

Several points:

  • Flink makes a strong distinction between the working state, which is always local (for good performance), and state snapshots (checkpoints and savepoints), which are not local (for reliability they should be stored in a distributed file system).

  • The RocksDBStateBackend uses the local disk for working state. The other two state backends keep their working state on the Java heap.

  • The checkpoint coordinator arranges for all of these slices of data scattered across all of the task managers to be collected together into complete checkpoints that are stored elsewhere. In the case of the MemoryStateBackend those checkpoints are stored on the JobManager heap; for the other two, they are in a distributed file system.

You want to configure RocksDB to use the fastest available local file system. Try to use locally attached SSDs, and avoid network-attached storage (such as EBS). Do not try to use a distributed file system such as S3 as RocksDB's local storage.

state.backend.rocksdb.localdir controls where each local RocksDB stores its working state.

The parameter to the RocksDBStateBackend constructor controls where the checkpoints are stored. E.g., using S3 as recommended by @ezequiel is the obvious choice on AWS.




回答2:


RocksDB can work with any supported Filesystem by Flink https://ci.apache.org/projects/flink/flink-docs-stable/ops/filesystems/

If you are running Flink probably you want to checkpoint, and resume from them.

I would externalise the storage outside the node. I you are using a cloud provider like AWS, then S3 is the right option.

So you should probably write something like: new RocksDBStateBackend("s3://my-bucket", true); and assing it to your execution environment.

Please check the above documentation to configure properly your filesystem.



来源:https://stackoverflow.com/questions/61655220/how-to-store-checkpoint-into-remote-rocksdb-in-apache-flink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!