When using Flink Table SQL in my project, I found that if there was any GROUP BY
clause in my SQL, the size of the checkpoint will increase vastly.
For example,
INSERT INTO COMPANY_POST_DAY
SELECT
sta_date,
company_id,
company_name
FROM
FCBOX_POST_COUNT_VIEW
The checkpoint size would be less than 500KB.
But when use like this,
INSERT INTO COMPANY_POST_DAY
SELECT
sta_date,
company_id,
company_name,
sum(ed_post_count)
FROM
FCBOX_POST_COUNT_VIEW
GROUP BY
sta_date, company_id, company_name, TUMBLE(procTime, INTERVAL '1' SECOND)
The checkpoint size would be more than 70MB, even when there is no any message processed. Like this,
But When using DataStream API and the keyBy
instead of Table SQL GROUP BY
,the checkpoint size would be normal, less than 1MB.
Why?
-------updated at 2019-03-25--------
After doing some tests and reading source code, we found that the reason for this was RocksDB.
When using RockDB as the state backend, the size of the checkpoint will be more than about 5MB per key, and when using filesystem as the state backend, the size of the checkpoint will fall down to less than 100KB per key.
Why do RocksDB need so much space to hold the state? When should we chooose RocksDB?