Good Morning, Afternoon & Evening! i have a Fl...
# troubleshooting
t
Good Morning, Afternoon & Evening! i have a Flink java app on my KDA and the data source is a KDS and have 2 sink and both are firehouse(one mainDS and one sideoutput). i have one operation on that data and its is a
ProcessFunction
and after that process function i just sink the data, the problem is that i am facing unevenly distribution of data across the parallelism, can someone please enlight me on this?
Here is the code
Copy code
/**
 * Hello world!
 *
 */
public class FlinkApp{

    private static final ObjectMapper jsonParser = new ObjectMapper();
    private static final String region = "cn-northwest-1";
    private static final String inputStreamName = "bot-webb-splunk-kinesis";

    private static final String FAIRNESS_FIREHOUSE = "fairness-firehouse";
    private static final String EDGEKV_FIREHOUSE = "bot-webb-splunk-firehose-edgekv";


    private static DataStream<String> createSourceFromStaticConfig(StreamExecutionEnvironment env) {
        Properties inputProperties = new Properties();
        inputProperties.setProperty(ConsumerConfigConstants.AWS_REGION, region);
        inputProperties.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "LATEST");

        return env.addSource(new FlinkKinesisConsumer<>(inputStreamName,
                new SimpleStringSchema(), inputProperties));
    }


    private static KinesisFirehoseSink<String> fairnessFirehoseSink() {
        Properties sinkProperties = new Properties();
        sinkProperties.setProperty(AWS_REGION, region);

        return KinesisFirehoseSink.<String>builder()
                .setFirehoseClientProperties(sinkProperties)
                .setSerializationSchema(new SimpleStringSchema())
                .setDeliveryStreamName(FAIRNESS_FIREHOUSE)
                .build();
    }

    private static KinesisFirehoseSink<String> edgeKVFirehoseSink() {
        Properties sinkProperties = new Properties();
        sinkProperties.setProperty(AWS_REGION, region);

        return KinesisFirehoseSink.<String>builder()
                .setFirehoseClientProperties(sinkProperties)
                .setSerializationSchema(new SimpleStringSchema())
                .setDeliveryStreamName(EDGEKV_FIREHOUSE)
                .build();
    }




    public static void main(String[] args) throws Exception {
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        final OutputTag<String> edgeKVOutput = new OutputTag<String>("edgekv-output"){};

        DataStream<DataRecord> input = createSourceFromStaticConfig(env).map(data -> jsonParser.readValue(data, DataRecord.class)).name("xxxxxxx-kinesis source");

        final SingleOutputStreamOperator<String> mainDS = input.process(new ProcessFunction<DataRecord, String>() {

            @Override
            public void processElement(DataRecord dataRecord, ProcessFunction<DataRecord, String>.Context ctx, Collector<String> out) throws Exception {
                if (dataRecord.getMetadata() != null && dataRecord.getMetadata().size() > 0) {
                    List<String> destinations = dataRecord.getMetadata().get(0).get("destination");
                    if (destinations != null && destinations.contains("fairness") && destinations.contains("edgeKV")) {
                        // emit data to edgeKV DataStream
                        ctx.output(edgeKVOutput, dataRecord.toString());
                        // emit data to fairness DataStream
                        out.collect(dataRecord.toString());
                    } else if (destinations != null && destinations.contains("fairness")) {
                        out.collect(dataRecord.toString());
                    } else if (destinations != null && destinations.contains("edgeKV")) {
                        ctx.output(edgeKVOutput, dataRecord.toString());
                    }
                }
            }
        }).name("Data Processor");

        DataStream<String> sideOutput = mainDS.getSideOutput(edgeKVOutput);

        sideOutput.sinkTo(fairnessFirehoseSink()).name("sink to EdgeKV Firehouse");
        mainDS.sinkTo(edgeKVFirehoseSink()).name("sink to Fairness Firehouse");

        env.execute("Minimum Stock Price");
    }
}
j
it appears as though the data coming into the source is skewed--can you check your Kinesis Data Stream shard metrics as well? Additionally, you could try disabling chaining to see the data distribution from source to your data processor to see where the skewness is occuring
t
thank you so much for your comment and as expected data in the data stream shard is skewed, i got another quest about the above first pic, i only got ~3k data and that line got busy 100% and thats sounds very odd
here too
j
Busy means the cpu is working. Not necessarily a bad thing unless throughput is slowing down. Is it taking a long time to process? You can look at the flame graph within this process to see where time is being spent
what shocking is that its reaching 100% busy at ~330 records
j
Any processing happening before the sink in the same task causing cpu to spike? Could try disabling chaining again to investigate
t
i am a newbi to the flink and i don’t know how to what is disabling the chaining mes 🥲
j
Essentially operators are chained by default unless a shuffle of data is required
t
thank u so much i will try to dig deeper with this info gratitude thank you
Thank you so much Jeremy! after disabling the chaining i foe the root cause and now everything is working as expected 🙏🏻
🥳 1
j
out of curiosity, what was it? Don’t forget to un-disable chaining as it can be degrading to performance.
gratitude thank you 1
t
My sink is not working as expected and never even send a single data to firehouse so I wrote Custom class which implements RichSinkFunction and send data by using firehouse client
And all the process logic are done in the invoke function
j
That is unfortunate that the sink was not working--any more details you can share about the issues with the Firehose sink?
t
my apologies for unable to get back to your question, recently i rewrote the processing and sink part using firehouseSink and the problem is due to typo in firehouse name, my colleague created that firehouse with
*-firehose
but in my code i wrote
*-firehouse
🤣.
🤦‍♂️ 1