Amazon Managed Streaming for Apache Kafka

Learn how Amazon Managed Streaming for Apache Kafka (MSK) aids in migrating Apache Kafka workloads to the cloud.

Amazon Managed Streaming for Apache Kafka (MSK) lets us easily build and run applications that handle real-time data streams. Amazon MSK acts like a highway system for data, allowing users to collect, process, and analyze it in real-time without having to manage the underlying infrastructure. It simplifies working with Apache Kafka, a popular open-source platform for stream processing, so users can focus on building applications.

Press + to interact

Amazon MSK components

Here’s a breakdown of the key components involved in an Amazon MSK cluster:

  • Topics, producers, and consumers: Topics are essentially categories or channels within the MSK cluster where data streams are published and consumed. Producers are applications or services that publish data streams to topics in the MSK cluster. They can write data in various formats depending on the application requirements. Consumers are applications or services that subscribe to topics of interest within the MSK cluster. They receive and process the data streams flowing through the subscribed topics.

  • Broker nodes: These are responsible for receiving, storing, replicating, and forwarding data: 

    • They act as entry points for producers to publish topics to the cluster.

    • Broker nodes durably store the published data within the cluster for a configurable period.

    • They replicate data across multiple availability zones for high availability and fault tolerance.

    • They forward data to consumers (applications processing the data) subscribed to the relevant topics.

  • Zookeeper ensemble: This is a separate group of servers that act as a distributed coordination system for the MSK cluster. Its primary responsibilities include:

    • Electing a leader broker node responsible for managing the overall cluster state and coordinating communication between other broker nodes.

    • Storing and distributing configuration information for the entire cluster, ensuring all broker nodes operate consistently.

    • Helping detect failures of broker nodes and triggers rebalancing of data to maintain availability.

  • Cluster operations: We can control and manage the MSK cluster using AWS Management Console, AWS Command Line Interface (AWS CLI), and SDK’s APIs.

Press + to interact
Amazon MSK components
Amazon MSK components

MSK vs. Kinesis

Amazon Kinesis is a real-time analytical service. However, MSK is specifically designed to run applications that use Apache Kafka. It allows us to run Kafka clusters and takes the responsibility of managing them while offering the user control over the clusters. It is suited for workloads that leverage the Kafka capabilities, such as event sourcing, stream processing, and log aggregation. It is typically used to migrate on-premises Kafka workloads to the cloud.

On the contrary, Amazon Kinesis is a proprietary AWS technology that integrates natively with other AWS services such as Redshift, S3, and more. The services scale automatically to handle large workloads. It is ideal for services specific to the cloud, such as log processing, real-time analytics, and more.

Use case: Managing IoT devices

In an internet of Things (IoT) scenario, Amazon MSK can be a powerful tool for managing devices’ constant data stream. Imagine thousands of sensors constantly sending data. Traditional data processing methods might struggle to keep up with this real-time data flow. This is where MSK comes in, by configuring the IoT devices as producers, they can publish data streams directly to MSK topics. MSK is a high-speed highway for this data, ensuring it reaches its destination quickly and reliably.

Meanwhile, EC2 instances launched as consumers can subscribe to specific topics. These EC2 instances receive and process real-time data streams. This setup enables real-time analytics, anomaly detection, and automated actions based on the data. For instance, an EC2 instance consuming a temperature sensor topic from the broker topics could trigger an alert if readings exceed safe limits, preventing potential equipment failures. MSK’s real-time processing capabilities make it ideal for handling the high volume and velocity of data from IoT devices, allowing us to gain valuable insights and automate actions from the constantly connected world.

Press + to interact
Connecting IoT devices with Amazon MSK
Connecting IoT devices with Amazon MSK

Get hands-on with 1300+ tech skills courses.