[mysql] Optimize pure binlog phase check logic to improve performance #1392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pure binlog phase performace opt
Our online business found that the performance of the binlog phase of Flink jobs could not meet the demand. Through performance analysis, we found that the performance bottleneck in the phase was the comparison of binlog offset. For each binlog data, mysql-cdc needs to judge whether the offset of the binlog data is after the end of the full snapshot phase (max split high watermark). If so, it is in pure binlog phase, and can be directly output to the downstream. The comparison between binlog data offset and max split high watermark consumes CPU very much and has become a performance bottleneck (see the following figure).
Further analysis of the internal logic of mysql-cdc shows that for each mysql-cdc table, the state of incremental synchronization will remain unchanged after entering the pure binlog phase. Therefore, it is sufficient to keep a flag for each table to judge whether the table has entered pure binlog phase, so as to avoid binlog offset comparison of each data in the pure binlog phase, Improve the performance of incremental data synchronization.
Performance improvement
In the actual online scenario test (more than 180 tables are synchronized with many table fields in a flink job), the performance is improved by 3 times (from 5k/s to 2w/s), which meets the real-time synchronization needs of our business.