Kimmo Sääskilahti
10/20/2023, 6:19 AM.keyBy(e => e.key).window(...) . The key here is badly skewed leading to performance issues.
To handle data skew, I was thinking of using the "salting" strategy explained in this article. So I would add a well-distributed key called, say, salt and first make aggregation .keyBy(e => (e.key, salt(e)).window(...) . Then I'd like to collect the results from each "salt" to produce a single result per (key, window). I'm struggling to understand how to do this in Flink.
I can add .keyBy((key, window)) after the "salted" calculation to collect results, but it is difficult to produce only one result. I can fire aggregated result per salt as they come in, but this not desired in downstream.
I was also thinking of adding a consecutive window like .keyBy(key).window(# same window as above) , but I'm a little confused how to ensure my windowing results from the first step end up in a correct window in the second step. Do I need to do some additional assignTimestampsAndWatermarks stuff here?
Any help very much appreciated 🙏