We have a flink application written on Java and running on AWS Kinesis Data Analytics. The application reads the input stream from AWS Managed Service Kafka (kafka topic 1), then apply business logic (some calculations) and finally writes the output to another Kafka topic (kafka topic 2).
The parallelism is 10 and the topic has 15 partitions. The expectation is to process ~20K concurrent data in 5 mins. But after all the optimizations we could bring it to a speed of ~20K concurrent data in 25 mins.
Could you please let me know if there is any other performance optimization that can be implemented to achieve the target.
Is Flink Async I/O going to be an option to further optimize?.
Sample code:-
StreamExecutionEnvironment streamenv =
StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<ObjectNode> initialStreamData = streamenv
.addSource(new FlinkKafkaConsumer<>(
TOPIC_NAME,
new ObjectNodeJsonDeSerializerSchema(),
kafkaConnectProperties);
initialStreamData.print();
DataStream<POJO> rawDataProcess = initialStreamData
.rebalance()
.flatMap(new ReProcessingDataProvider())
.keyBy(value -> value.getPersonId());
rawDataProcess.print();
DataStream<POJO> cgmStream = rawDataProcess
.keyBy(new ReProcessorKeySelector())
.rebalance()
.flatMap(new SgStreamTask());
cgmStream.print();
DataStream<POJO> artfctOverlapStream = null;
artfctOverlapStream = cgmStreamData
.keyBy(new CGMKeySelector())
.countWindow(2, 1)
.apply(new ArtifactOverlapProvider()); //the same person_id key
cgmStreamData.print();
DataStream<POJO> streamWithSgRoc = null;
streamWithSgRoc = artfctOverlapStream
.keyBy(new CGMKeySelector())
.countWindow(7, 1)
.apply(new SgRocProvider()); // the same person_id key
streamWithSgRoc.print();
DataStream<POJO> cgmExcursionStream = null;
cgmExcursionStream = streamWithSgRoc
.keyBy(new CGMKeySelector())
.countWindow(Common.THREE, Common.ONE)
.apply(new CGMExcursionProviderStream()); //the same person_id key
cgmExcursionStream.print();
cgmExcursionStream
.addSink(new FlinkKafkaProducer<CGMDataCollector>(
topicsProperties.getProperty(Common.CGM_EVENT_TOPIC),
new CGMDataCollectorSchema(),
kafkaConnectProperties));