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
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
- Producers (customer code) take data from sources such as Kinesis, IoT or RDS and write it to a topic.
- The topic's partitions live on brokers, and are replicated to other brokers in other AZs.
- 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:
Move to Amazon MSK; MSK Serverless removes capacity management completely (clients must use IAM access control). The Kafka APIs stay the same.
A Managed Service for Apache Flink application reading from the stream, with one-minute windows, writing the results to a destination such as S3 or another stream.
AWS documentation
AWS Lake Formation
AWS Lake Formation for building a data lake on S3 in days, its blueprints and Glue foundations, and centralized fine-grained permissions at the row, column and cell level.
Big data ingestion pipeline
A fully serverless big data pipeline on AWS, from IoT devices through Kinesis, Firehose, S3, Lambda and Athena to QuickSight and Redshift, and why each piece is there.