Creating a Managed Service for Apache Flink application - Managed Service for Apache Flink
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon Managed Service for Apache Flink was previously known as Amazon Kinesis Data Analytics for Apache Flink.

Creating a Managed Service for Apache Flink application

This topic contains information about creating a Managed Service for Apache Flink.

Building your Managed Service for Apache Flink application code

This section describes the components that you use to build the application code for your Managed Service for Apache Flink application.

We recommend that you use the latest supported version of Apache Flink for your application code. For information about upgrading Managed Service for Apache Flink applications, see In-place version upgrades for Apache Flink.

You build your application code using Apache Maven. An Apache Maven project uses a pom.xml file to specify the versions of components that it uses.

Note

Managed Service for Apache Flink supports JAR files up to 512 MB in size. If you use a JAR file larger than this, your application will fail to start.

Applications can now use the Java API from any Scala version. You must bundle the Scala standard library of your choice into your Scala applications.

For information about creating a Managed Service for Apache Flink application that uses Apache Beam, see Using Apache Beam.

When using Managed Service for Apache Flink Runtime version 1.1.0 and later, you specify the version of Apache Flink that your application uses when you compile your application. You provide the version of Apache Flink with the -Dflink.version parameter. For example, if you are using Apache Flink 1.19.1, provide the following:

mvn package -Dflink.version=1.19.1

For building applications with earlier versions of Apache Flink, see Earlier versions.

Creating your Managed Service for Apache Flink application

After you have built your application code, you do the following to create your Managed Service for Apache Flink application:

  • Upload your Application code: Upload your application code to an Amazon S3 bucket. You specify the S3 bucket name and object name of your application code when you create your application. For a tutorial that shows how to upload your application code, see the Getting started (DataStream API) tutorial.

  • Create your Managed Service for Apache Flink application: Use one of the following methods to create your Managed Service for Apache Flink application:

    • Create your Managed Service for Apache Flink application using the Amazon console: You can create and configure your application using the Amazon console.

      When you create your application using the console, your application's dependent resources (such as CloudWatch Logs streams, IAM roles, and IAM policies) are created for you.

      When you create your application using the console, you specify what version of Apache Flink your application uses by selecting it from the pull-down on the Managed Service for Apache Flink - Create application page.

      For a tutorial about how to use the console to create an application, see the Getting started (DataStream API) tutorial.

    • Create your Managed Service for Apache Flink application using the Amazon CLI: You can create and configure your application using the Amazon CLI.

      When you create your application using the CLI, you must also create your application's dependent resources (such as CloudWatch Logs streams, IAM roles, and IAM policies) manually.

      When you create your application using the CLI, you specify what version of Apache Flink your application uses by using the RuntimeEnvironment parameter of the CreateApplication action.

    Note

    You can change the RuntimeEnvironment of an existing application. To learn how, see In-place version upgrades for Apache Flink.

Starting your Managed Service for Apache Flink application

After you have built your application code, uploaded it to S3, and created your Managed Service for Apache Flink application, you then start your application. Starting a Managed Service for Apache Flink application typically takes several minutes.

Use one of the following methods to start your application:

  • Start your Managed Service for Apache Flink application using the Amazon console: You can run your application by choosing Run on your application's page in the Amazon console.

  • Start your Managed Service for Apache Flink application using the Amazon API: You can run your application using the StartApplication action.

Verifying your Managed Service for Apache Flink application

You can verify that your application is working in the following ways:

  • Using CloudWatch Logs: You can use CloudWatch Logs and CloudWatch Logs Insights to verify that your application is running properly. For information about using CloudWatch Logs with your Managed Service for Apache Flink application, see Logging and monitoring.

  • Using CloudWatch Metrics: You can use CloudWatch Metrics to monitor your application's activity, or activity in the resources your application uses for input or output (such as Kinesis streams, Firehose streams, or Amazon S3 buckets.) For more information about CloudWatch metrics, see Working with Metrics in the Amazon CloudWatch User Guide.

  • Monitoring Output Locations: If your application writes output to a location (such as an Amazon S3 bucket or database), you can monitor that location for written data.

Enabling system rollbacks for your Managed Service for Apache Flink application

With system-rollback capability, you can achieve higher availability of your running Apache Flink application on Amazon Managed Service for Apache Flink. Opting into this configuration enables the service to automatically revert the application to the previously running version when an action such as UpdateApplication or autoscaling runs into code or configurations bugs.

Note

To use the system rollback feature, you must opt in by updating your application. Existing applications will not automatically use system rollback by default.

How it works

When you initiate an application operation, such as an update or scaling action, the Amazon Managed Service for Apache Flink first attempts to run that operation. If it detects issues that prevent the operation from succeeding, such as code bugs or insufficient permissions, the service automatically initiates a RollbackApplication operation.

The rollback attempts to restore the application to the previous version that ran successfully, along with the associated application state. If the rollback is successful, your application continues processing data with minimal downtime using the previous version. If the automatic rollback also fails, Amazon Managed Service for Apache Flink transitions the application to the READY status, so that you can take further actions, including fixing the error and retrying the operation.

You must opt in to use automatic system rollbacks. You can enable it using the console or API for all operations on your application from this point forward.

The following example request for the UpdateApplication action enables system rollbacks for an application:

{ "ApplicationName": "MyApplication", "CurrentApplicationVersionId": 1, "ApplicationConfigurationUpdate": { "ApplicationSystemRollbackConfigurationUpdate": { "RollbackEnabledUpdate": "true" } } }

Common scenarios

The following scenarios illustrate where automatic system rollbacks are beneficial:

  • Application updates: If you update your application with new code that has bugs when initializing the Flink job through the main method, the automatic rollback allows the previous working version to be restored. Other update scenarios where system rollbacks are helpful include:

    • If your application is updated to run with a parallelism higher than maxParallelism.

    • If your application is updated to run with incorrect subnets for a VPC application that results in a failure during the Flink job startup.

  • Flink version upgrades: When you upgrade to a new Apache Flink version and the upgraded application encounters a snapshot compatibility issue, system rollback lets you revert to the prior Flink version automatically.

  • AutoScaling: When the application scales up but runs into issues restoring from a savepoint, due to operator mismatch between the snapshot and the Flink job graph.

Operation APIs

To provide better visibility, Amazon Managed Service for Apache Flink has two APIs related to application operations that can help you track failures and related system rollbacks.

ListApplicationOperations

This API lists all operations performed on the application, including UpdateApplication, Maintenance, RollbackApplication, and others in reverse chronological order. The following example request for the ListApplicationOperations action lists the first 10 application operations for the application:

{ "ApplicationName": "MyApplication", "Limit": 10 }

This following example request for ListApplicationOperations helps filter the list to previous updates on the application:

{ "ApplicationName": "MyApplication", "operation": "UpdateApplication" }

DescribeApplicationOperation

This API provides detailed information about a specific operation listed by ListApplicationOperations, including the reason for failure, if applicable. The following example request for the DescribeApplicationOperation action lists details for a specific application operation:

{ "ApplicationName": "MyApplication", "OperationId": "xyzoperation" }

For troubleshooting information, see System rollback best practices.