How do I time the checkpointing in Apache Flink streaming?

Tags: , ,

I am running the Fraud Detector example of Apache Flink with RocksDB as my state backend. I want to know how long does Apache Flink takes to checkpoint the state.

My approach is to print time before and after the checkpoint functions.

I could not find the function/class or any piece of code that checkpoints the state I tried debugging through the IDE but in vain.

This is what I have gone through so far:

 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package spendreport;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.walkthrough.common.sink.AlertSink;
import org.apache.flink.walkthrough.common.entity.Alert;
import org.apache.flink.walkthrough.common.entity.Transaction;
import org.apache.flink.walkthrough.common.source.TransactionSource;
import org.apache.flink.contrib.streaming.state.RocksDBStateBackend;


 * Skeleton code for the datastream walkthrough
public class FraudDetectionJob {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//      env.setStateBackend(new RocksDBStateBackend(filebackend, true));

        // Enabling Checkpoint
        long checkpointInterval = 5000;

        // Enable Web UI
//      Configuration conf = new Configuration();
//      env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

        DataStream<Transaction> transactions = env
            .addSource(new TransactionSource())

        DataStream<Alert> alerts = transactions
                .process(new FraudDetector())

            .addSink(new AlertSink())

        env.execute("Fraud Detection");

I step into the execute function and find many places where the code sets the config for checkpoint (such as checking the timeout interval, etc). However, I could not find the function that actually checks executes the checkpointing.


It won’t be easy to measure this on your own, since checkpointing is done partly in the thread that runs your user functions, and partly asynchronously in another thread.

The best way to get some information about the impact of checkpointing is to look at the checkpointing metrics, which are conveniently collected together and displayed in the web UI:

enter image description here

Normally the web UI isn’t available when you are running in the IDE, but you can change this:

Configuration conf = new Configuration();
env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

For this to work, you’ll also have to add this dependency:


Source: stackoverflow