State backends
A state backend determines how Flink stores the state of your jobs while they run. Cloudera SQL Stream Builder jobs use the same state backend configuration as Flink jobs.
Flink offers the following state backends:
- RocksDB
- Stores the in-flight data in a RocksDB database in the local data directories of the TaskManagers. It writes asynchronous snapshots. The data is stored as serialized byte arrays. Keys are compared byte by byte. Cloudera recommends RocksDB for large state, long windows, and high-availability setups. The amount of state is limited only by the available disk space, but throughput is lower than with in-memory state. RocksDB is the only state backend that supports incremental snapshots.
- Hashmap
- Stores the data as objects on the Java heap. Key-value state and window operators hold hash tables with the values and triggers. Cloudera recommends Hashmap for small and moderate state. Access is faster, but the size of the state is limited by the memory of the Flink cluster.
Choose the state backend based on your performance and scalability needs. For a comparison of the state backends, see Flink state backends in the Apache Flink documentation.
To set the state backend for a single job, in session mode or in application mode, use a
SET statement before the query:
SET 'state.backend.type' = 'rocksdb';
or:
SET 'state.backend.type' = 'hashmap';
For the RocksDB options, see RocksDB state backend.
