Skip to Content

Managed Flink and Amazon MSK

Amazon Managed Service for Apache Flink for real-time stream processing, Amazon MSK for managed Apache Kafka, how Kafka works, Kinesis Data Streams vs MSK, and MSK consumers.

Amazon Managed Service for Apache Flink: applications written in Java, Python or SQL read from Kinesis Data Streams or Amazon MSK and write results to destinations such as S3, another Kinesis data stream or OpenSearch; Firehose cannot be a source Amazon Managed Service for Apache Flink: applications written in Java, Python or SQL read from Kinesis Data Streams or Amazon MSK and write results to destinations such as S3, another Kinesis data stream or OpenSearch; Firehose cannot be a source

Process streams from Kinesis or Kafka in real time.

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

  • Apache Flink (Java, Scala, Python or SQL) is a framework for processing data streams: filtering, aggregating over time windows, joining streams, detecting anomalies.
  • Sources: Kinesis Data Streams and Amazon MSK.
  • Run any Apache Flink application on a managed cluster on AWS:
    • provisioned compute resources, parallel computation, automatic scaling;
    • application backups (implemented as checkpoints and snapshots);
    • use any Apache Flink programming feature to transform data.
  • Important: Flink does not read from Amazon Data Firehose.

Amazon MSK

Amazon MSK (Managed Streaming for Apache Kafka) is fully managed Apache Kafka on AWS: an alternative to Amazon Kinesis.

  • Supports creating, updating and deleting clusters.
  • MSK creates and manages the Kafka broker nodes (and the ZooKeeper nodes or KRaft controllers that keep cluster metadata).
  • Deploy the MSK cluster in the customer's VPC, across multiple AZs (up to 3, for high availability).
  • Automatic recovery from common Apache Kafka failures.
  • Data is stored on EBS volumes for as long as needed (and tiered storage can move older data to a cheaper tier).
  • MSK Serverless: run Apache Kafka without managing capacity. MSK provisions resources and scales compute and storage automatically. It requires IAM access control.
  • MSK Connect runs managed Kafka Connect connectors to move data to and from S3, OpenSearch and databases.

Apache Kafka at a high level

Amazon MSK: producers written by the customer send records to topics on an MSK cluster whose brokers replicate partitions across up to three Availability Zones; consumers such as Managed Service for Apache Flink, Glue streaming ETL, Lambda or the customer's own apps on EC2, ECS or EKS read them Amazon MSK: producers written by the customer send records to topics on an MSK cluster whose brokers replicate partitions across up to three Availability Zones; consumers such as Managed Service for Apache Flink, Glue streaming ETL, Lambda or the customer's own apps on EC2, ECS or EKS read them

Producers write to topics; consumers poll them.
  1. Producers (customer code) take data from sources such as Kinesis, IoT or RDS and write it to a topic.
  2. The topic's partitions live on brokers, and are replicated to other brokers in other AZs.
  3. Consumers (customer code) poll from the topic and send the data on, to EMR, S3, SageMaker, Kinesis, RDS…

MSK consumers include:

  • Managed Service for Apache Flink;
  • AWS Glue streaming ETL jobs (powered by Apache Spark Streaming);
  • Lambda (MSK as an event source);
  • the customer's own applications on EC2, ECS or EKS.

Kinesis Data Streams vs Amazon MSK

Kinesis Data Streams:

  • Records up to 10 MiB (1 MB in the slides).
  • Data streams with shards.
  • Shard splitting and merging.
  • TLS in-flight encryption.
  • KMS at-rest encryption.

Amazon MSK:

  • 1 MB messages by default, configurable higher (for example 10 MB).
  • Kafka topics with partitions.
  • Partitions can only be added to a topic.
  • PLAINTEXT or TLS in-flight encryption.
  • KMS at-rest encryption.

Choose MSK when Kafka is already in use (tools, code, skills) or need Kafka features; choose Kinesis for a simpler, AWS-native, serverless stream.

Updated since the slides

Kinesis Data Streams now accepts records of up to 10 MiB, not 1 MB, so record size alone is no longer a reason to pick MSK. MSK has also added Express brokers (more throughput per broker, faster scaling, no storage to manage) and KRaft mode, which replaces ZooKeeper.

Real-world examples

  • A ride-hailing app streams driver locations into Kinesis Data Streams, and a Managed Flink application computes surge pricing per area every 10 seconds.
  • A bank moves its on-premises Kafka cluster to MSK with no code changes, and a Glue streaming ETL job writes the transactions to S3.

Exam tips

  • "Real-time analytics or transformations on a stream" → Managed Service for Apache Flink.
  • "Kafka", "migrate an existing Kafka cluster", "Kafka without managing servers" → Amazon MSK (MSK Serverless).
  • "Read from MSK" → Flink, Glue streaming ETL, Lambda, or apps on EC2/ECS/EKS.
  • "Kinesis Data Analytics" in an old question → Managed Service for Apache Flink.

Common traps

  • "Flink reads from Firehose." Its streaming sources are Kinesis Data Streams and MSK.
  • "MSK is serverless by default." Provisioned MSK has brokers the customer sizes; only MSK Serverless removes capacity management.
  • "Remove partitions from a Kafka topic." They can only be added.

Check yourself

An MSK cluster or Flink application costs dollars per day even when idle, so instead:

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt