Running Apache Kafka on AWS with Amazon MSK
This lesson explains how Amazon Managed Streaming for Apache Kafka (Amazon MSK) runs Kafka clusters for you, so teams with existing Kafka applications, skills or tooling can move to AWS without rewriting them.
Learning outcomes
After completing this lesson, you will be able to:
- Describe Kafka topics, partitions, brokers and consumer groups.
- Choose between MSK Provisioned and MSK Serverless.
- Describe how MSK Connect runs source and sink connectors.
- Choose between Amazon MSK and Kinesis Data Streams.
Kafka concepts
Apache Kafka, which Amazon MSK runs, organises streaming data with a few concepts. A topic is a named stream of records, such as orders. Each topic is divided into partitions, ordered subsets that are the unit of parallelism: records in one partition stay in order, and different partitions can be processed at the same time. Brokers are the servers that store partitions and serve producers and consumers.
Consumers belong to a consumer group, which shares a topic's partitions among its members, so adding consumers spreads the load; each group reads the whole topic independently of other groups. A consumer's position in a partition is its offset, which it commits so that it can resume where it left off after a restart. The following table summarises the concepts.
| Concept | Meaning |
|---|---|
| Topic | A named stream of records |
| Partition | An ordered subset of a topic; the unit of parallelism and ordering |
| Broker | A server that stores partitions and serves producers and consumers |
| Consumer group | A set of consumers that share a topic's partitions; each group reads the topic independently |
| Offset | A consumer's position in a partition, committed so that it can resume after a restart |
The following diagram shows a topic's partitions and two consumer groups reading them independently.

Kafka vocabulary
Cluster types
Amazon MSK offers two cluster types, which differ in who manages capacity. With MSK Provisioned, you choose the broker instance type, the number of brokers and the storage, and have fine control of Kafka's configuration; optional tiered storage moves older data to low-cost storage for long retention. It suits steady workloads and teams that tune Kafka. With MSK Serverless, capacity scales automatically and there are no brokers to size, which suits variable traffic and teams that want Kafka without capacity planning. The following table summarises the two types.
| Type | Capacity | Best for |
|---|---|---|
| MSK Provisioned | You choose broker type, broker count and storage; optional tiered storage for cheap long-term retention | Steady workloads and fine control of Kafka configuration |
| MSK Serverless | Capacity scales automatically; no brokers to size | Variable traffic and teams that want Kafka without capacity planning |
Retention is configurable per topic and can be unlimited, which suits event sourcing and replay by many consumer groups.
Provisioned or Serverless?
MSK Connect
MSK Connect runs Kafka Connect connectors as a managed service. Sink connectors write topics to S3, OpenSearch or databases; source connectors, such as Debezium, capture changes from databases into topics. Connectors scale by workers and need no servers to manage.
Security
Amazon MSK secures clusters in several layers. Clients authenticate with IAM access control, which uses IAM policies to authorise actions on topics and consumer groups; with mutual TLS, using client certificates; or with SASL/SCRAM, using user names and passwords stored in AWS Secrets Manager. IAM access control is usually the simplest choice for clients running on AWS, because no separate credentials are needed.
Data is encrypted at rest with AWS KMS and in transit with TLS, both between clients and brokers and between brokers. Clusters run inside the customer's VPC, and multi-VPC private connectivity, based on AWS PrivateLink, lets clients in other VPCs or accounts connect privately without peering the networks.
Securing MSK
MSK or Kinesis?
MSK and Kinesis Data Streams both provide durable, ordered streams, so the choice is mainly about the ecosystem and control. Amazon MSK runs standard Apache Kafka, so it is the answer when existing applications already use Kafka's APIs and tools, when data must be retained for a very long time, or when detailed control of Kafka's configuration is needed. Kinesis Data Streams is a simpler AWS-native service with deep integrations, such as Lambda, Firehose and IAM, and little to operate. The following table summarises the choice.
| Choose | When |
|---|---|
| Amazon MSK | Existing Kafka applications, Kafka APIs and ecosystem tools, very long retention or fine configuration control |
| Kinesis Data Streams | A simpler, AWS-native service with deep integrations and little to operate |
MSK or Kinesis?
Kinesis or MSK for a migration?
The choice between Kinesis and Amazon MSK depends on the existing environment. The following table identifies the appropriate service for each situation and the reason for the choice.
| Situation | Choice | Why |
|---|---|---|
| A company runs Apache Kafka on premises with Kafka Connect and existing consumers | Amazon MSK | Same Kafka APIs; applications move without rewriting |
| A new AWS-native application with Lambda consumers and little operations staff | Kinesis Data Streams (on-demand) | Serverless, simple integration |
| Events must be kept for months and replayed by many consumer groups | MSK (tiered storage) | Long, cheap retention |
| Variable Kafka traffic, no wish to size brokers | MSK Serverless | Kafka without capacity planning |
For the on-premises Kafka migration, MSK Connect can also take over the existing Kafka Connect connectors, for example an S3 sink that lands topics in the data lake, so the whole streaming estate moves with little change.
How are Kafka topics moved into S3 or databases without writing consumers?
Show answer
With MSK Connect, which runs Kafka Connect connectors as a managed service.
Exam Tips
Remember for the exam
- Existing Kafka applications, or a requirement for Kafka APIs, point to Amazon MSK.
- Kafka without capacity planning is MSK Serverless.
- To move Kafka topics to S3 or databases with connectors, use MSK Connect.
- To capture database changes into Kafka, run a Debezium source connector on MSK Connect.
- For cheap long-term retention on provisioned clusters, use tiered storage.