Apache Kafka is a well-liked open supply distributed streaming platform that’s broadly used within the AWS ecosystem. It’s designed to deal with real-time, high-throughput information streams, making it well-suited for constructing real-time information pipelines to fulfill the streaming wants of recent cloud-based purposes.
For AWS clients trying to run Apache Kafka, however don’t need to fear in regards to the undifferentiated heavy lifting concerned with self-managing their Kafka clusters, Amazon Managed Streaming for Apache Kafka (Amazon MSK) presents absolutely managed Apache Kafka. This implies Amazon MSK provisions your servers, configures your Kafka clusters, replaces servers once they fail, orchestrates server patches and upgrades, makes certain clusters are architected for top availability, makes certain information is durably saved and secured, units up monitoring and alarms, and runs scaling to assist load modifications. With a managed service, you possibly can spend your time creating and operating streaming occasion purposes.
For purposes to make use of information despatched to Kafka, you have to write, deploy, and handle software code that consumes information from Kafka.
Kafka Join is an open-source part of the Kafka challenge that gives a framework for connecting with exterior methods similar to databases, key-value shops, search indexes, and file methods out of your Kafka clusters. On AWS, our clients generally write and handle connectors utilizing the Kafka Join framework to maneuver information out of their Kafka clusters into persistent storage, like Amazon Easy Storage Service (Amazon S3), for long-term storage and historic evaluation.
At scale, clients have to programmatically handle their Kafka Join infrastructure for constant deployments when updates are required, in addition to the code for error dealing with, retries, compression, or information transformation as it’s delivered out of your Kafka cluster. Nevertheless, this introduces a necessity for funding into the software program improvement lifecycle (SDLC) of this administration software program. Though the SDLC is an economical and time-efficient course of to assist improvement groups construct high-quality software program, for a lot of clients, this course of is just not fascinating for his or her information supply use case, notably once they might dedicate extra assets in the direction of innovating for different key enterprise differentiators. Past SDLC challenges, many shoppers face fluctuating information streaming throughput. As an illustration:
- On-line gaming companies expertise throughput variations primarily based on sport utilization
- Video streaming purposes see modifications in throughput relying on viewership
- Conventional companies have throughput fluctuations tied to client exercise
Hanging the suitable steadiness between assets and workload might be difficult. Beneath-provisioning can result in client lag, processing delays, and potential information loss throughout peak hundreds, hampering real-time information flows and enterprise operations. However, over-provisioning leads to underutilized assets and pointless excessive prices, making the setup economically inefficient for purchasers. Even the motion of scaling up your infrastructure introduces extra delays as a result of assets should be provisioned and bought on your Kafka Join cluster.
Even when you possibly can estimate aggregated throughput, predicting throughput per particular person stream stays troublesome. Consequently, to attain clean operations, you would possibly resort to over-provisioning your Kafka Join assets (CPU) on your streams. This strategy, although useful, may not be probably the most environment friendly or cost-effective answer.
Prospects have been asking for a totally serverless answer that won’t solely deal with managing useful resource allocation, however transition the price mannequin to solely pay for the info they’re delivering from the Kafka matter, as a substitute of underlying assets that require fixed monitoring and administration.
In September 2023, we introduced a brand new integration between Amazon and Amazon Knowledge Firehose, permitting builders to ship information from their MSK matters to their vacation spot sinks with a totally managed, serverless answer. With this new integration, you now not wanted to develop and handle your individual code to learn, remodel, and write your information to your sink utilizing Kafka Join. Knowledge Firehose abstracts away the retry logic required when studying information out of your MSK cluster and delivering it to the specified sink, in addition to infrastructure provisioning, as a result of it might probably scale out and scale in mechanically to regulate to the amount of knowledge to switch. There aren’t any provisioning or upkeep operations required in your facet.
At launch, the checkpoint time to begin consuming information from the MSK matter was the creation time of the Firehose stream. Knowledge Firehose couldn’t begin studying from different factors on the info stream. This induced challenges for a number of completely different use instances.
For patrons which might be organising a mechanism to sink information from their cluster for the primary time, all information within the matter older than the timestamp of Firehose stream creation would wish one other approach to be persevered. For instance, clients utilizing Kafka Join connectors, like These customers had been restricted in utilizing Knowledge Firehose as a result of they wished to sink all the info from the subject to their sink, however Knowledge Firehose couldn’t learn information from sooner than the timestamp of Firehose stream creation.
For different clients that had been operating Kafka Join and wanted emigrate from their Kafka Join infrastructure to Knowledge Firehose, this required some further coordination. The discharge performance of Knowledge Firehose means you possibly can’t level your Firehose stream to a selected level on the supply matter, so a migration requires stopping information ingest to the supply MSK matter and ready for Kafka Hook up with sink all the info to the vacation spot. Then you possibly can create the Firehose stream and restart the producers such that the Firehose stream can then devour new messages from the subject. This provides extra, and non-trivial, overhead to the migration effort when making an attempt to chop over from an present Kafka Join infrastructure to a brand new Firehose stream.
To deal with these challenges, we’re completely satisfied to announce a brand new function within the Knowledge Firehose integration with Amazon MSK. Now you can specify the Firehose stream to both learn from the earliest place on the Kafka matter or from a customized timestamp to start studying out of your MSK matter.
Within the first put up of this sequence, we targeted on managed information supply from Kafka to your information lake. On this put up, we lengthen the answer to decide on a customized timestamp on your MSK matter to be synced to Amazon S3.
Overview of Knowledge Firehose integration with Amazon MSK
Knowledge Firehose integrates with Amazon MSK to supply a totally managed answer that simplifies the processing and supply of streaming information from Kafka clusters into information lakes saved on Amazon S3. With only a few clicks, you possibly can repeatedly load information out of your desired Kafka clusters to an S3 bucket in the identical account, eliminating the necessity to develop or run your individual connector purposes. The next are among the key advantages to this strategy:
- Totally managed service – Knowledge Firehose is a totally managed service that handles the provisioning, scaling, and operational duties, permitting you to give attention to configuring the info supply pipeline.
- Simplified configuration – With Knowledge Firehose, you possibly can arrange the info supply pipeline from Amazon MSK to your sink with only a few clicks on the AWS Administration Console.
- Computerized scaling – Knowledge Firehose mechanically scales to match the throughput of your Amazon MSK information, with out the necessity for ongoing administration.
- Knowledge transformation and optimization – Knowledge Firehose presents options like JSON to Parquet/ORC conversion and batch aggregation to optimize the delivered file measurement, simplifying information analytical processing workflows.
- Error dealing with and retries – Knowledge Firehose mechanically retries information supply in case of failures, with configurable retry durations and backup choices.
- Offset choose possibility – With Knowledge Firehose, you possibly can choose the beginning place for the MSK supply stream to be delivered inside a subject from three choices:
- Firehose stream creation time – This lets you ship information ranging from Firehose stream creation time. When migrating from to Knowledge Firehose, when you have an choice to pause the producer, you possibly can take into account this feature.
- Earliest – This lets you ship information ranging from MSK matter creation time. You’ll be able to select this feature when you’re setting a brand new supply pipeline with Knowledge Firehose from Amazon MSK to Amazon S3.
- At timestamp – This selection permits you to present a selected begin date and time within the matter from the place you need the Firehose stream to learn information. The time is in your native time zone. You’ll be able to select this feature when you favor to not cease your producer purposes whereas migrating from Kafka Hook up with Knowledge Firehose. You’ll be able to discuss with the Python script and steps offered later on this put up to derive the timestamp for the newest occasions in your matter that had been consumed by Kafka Join.

The next are advantages of the brand new timestamp choice function with Knowledge Firehose:
- You’ll be able to choose the beginning place of the MSK matter, not simply from the purpose that the Firehose stream is created, however from any level from the earliest timestamp of the subject.
- You’ll be able to replay the MSK stream supply if required, for instance within the case of testing situations to pick from completely different timestamps with the choice to pick from a selected timestamp.
- When migrating from Kafka Hook up with Knowledge Firehose, gaps or duplicates might be managed by deciding on the beginning timestamp for Knowledge Firehose supply from the purpose the place Kafka Join supply ended. As a result of the brand new customized timestamp function isn’t monitoring Kafka client offsets per partition, the timestamp you choose on your Kafka matter must be a couple of minutes earlier than the timestamp at which you stopped Kafka Join. The sooner the timestamp you choose, the extra duplicate information you’ll have downstream. The nearer the timestamp to the time of Kafka Join stopping, the upper the probability of knowledge loss if sure partitions have fallen behind. Make sure to choose a timestamp acceptable to your necessities.
Overview of answer
We talk about two situations to stream information.
In State of affairs 1, we migrate to Knowledge Firehose from Kafka Join with the next steps:
- Derive the newest timestamp from MSK occasions that Kafka Join delivered to Amazon S3.
- Create a Firehose supply stream with Amazon MSK because the supply and Amazon S3 because the vacation spot with the subject beginning place as Earliest.
- Question Amazon S3 to validate the info loaded.
In State of affairs 2, we create a brand new information pipeline from Amazon MSK to Amazon S3 with Knowledge Firehose:
- Create a Firehose supply stream with Amazon MSK because the supply and Amazon S3 because the vacation spot with the subject beginning place as At timestamp.
- Question Amazon S3 to validate the info loaded.
The answer structure is depicted within the following diagram.

Stipulations
It’s best to have the next stipulations:
- An AWS account and entry to the next AWS providers:
- An MSK provisioned or MSK serverless cluster with matters created and information streaming to it. The pattern matter utilized in that is
order. - An EC2 occasion configured to make use of as a Kafka admin shopper. Consult with Create an IAM function for directions to create the shopper machine and IAM function that you’ll want to run instructions in opposition to your MSK cluster.
- An S3 bucket for delivering information from Amazon MSK utilizing Knowledge Firehose.
- Kafka Hook up with ship information from Amazon MSK to Amazon S3 if you wish to migrate from Kafka Join (State of affairs 1).
Migrate to Knowledge Firehose from Kafka Join
To cut back duplicates and reduce information loss, you have to configure your customized timestamp for Knowledge Firehose to learn occasions as near the timestamp of the oldest dedicated offset that Kafka Join reported. You’ll be able to observe the steps on this part to visualise how the timestamps of every dedicated offset will range by partition throughout the subject you need to learn from. That is for demonstration functions and doesn’t scale as an answer for workloads with numerous partitions.
Pattern information was generated for demonstration functions by following the directions referenced within the following GitHub repo. We arrange a pattern producer software that generates clickstream occasions to simulate customers looking and performing actions on an imaginary ecommerce web site.
To derive the newest timestamp from MSK occasions that Kafka Join delivered to Amazon S3, full the next steps:
- Out of your Kafka shopper, question Amazon MSK to retrieve the Kafka Join client group ID:

- Cease Kafka Join.
- Question Amazon MSK for the newest offset and related timestamp for the patron group belonging to Kafka Join.
You need to use the get_latest_offsets.py Python script from the next GitHub repo as a reference to get the timestamp related to the newest offsets on your Kafka Join client group. To allow authentication and authorization for a non-Java shopper with an IAM authenticated MSK cluster, discuss with the next GitHub repo for directions on putting in the aws-msk-iam-sasl-signer-python bundle on your shopper.

Word the earliest timestamp throughout all of the partitions.
Create a knowledge pipeline from Amazon MSK to Amazon S3 with Knowledge Firehose
The steps on this part are relevant to each situations. Full the next steps to create your information pipeline:
- On the Knowledge Firehose console, select Firehose streams within the navigation pane.
- Select Create Firehose stream.

- For Supply, select Amazon MSK.
- For Vacation spot, select Amazon S3.

- For Supply settings, browse to the MSK cluster and enter the subject title you created as a part of the stipulations.
- Configure the Firehose stream beginning place primarily based in your situation:
- For State of affairs 1, set Matter beginning place as At Timestamp and enter the timestamp you famous within the earlier part.

- For State of affairs 2, set Matter beginning place as Earliest.

- For State of affairs 1, set Matter beginning place as At Timestamp and enter the timestamp you famous within the earlier part.
- For Firehose stream title, go away the default generated title or enter a reputation of your choice.
- For Vacation spot settings, browse to the S3 bucket created as a part of the stipulations to stream information.
Inside this S3 bucket, by default, a folder construction with YYYY/MM/dd/HH will probably be mechanically created. Knowledge will probably be delivered to subfolders pertaining to the HH subfolder in keeping with the Knowledge Firehose to Amazon S3 ingestion timestamp.

- Beneath Superior settings, you possibly can select to create the default IAM function for all of the permissions that Knowledge Firehose wants or select present an IAM function that has the insurance policies that Knowledge Firehose wants.

- Select Create Firehose stream.

On the Amazon S3 console, you possibly can confirm the info streamed to the S3 folder in keeping with your chosen offset settings.

Clear up
To keep away from incurring future fees, delete the assets you created as a part of this train when you’re not planning to make use of them additional.
Conclusion
Knowledge Firehose offers a simple approach to ship information from Amazon MSK to Amazon S3, enabling you to save lots of prices and scale back latency to seconds. To attempt Knowledge Firehose with Amazon S3, discuss with the Supply to Amazon S3 utilizing Amazon Knowledge Firehose lab.
Concerning the Authors
Swapna Bandla is a Senior Options Architect within the AWS Analytics Specialist SA Group. Swapna has a ardour in the direction of understanding clients information and analytics wants and empowering them to develop cloud-based well-architected options. Exterior of labor, she enjoys spending time along with her household.
Austin Groeneveld is a Streaming Specialist Options Architect at Amazon Net Providers (AWS), primarily based within the San Francisco Bay Space. On this function, Austin is obsessed with serving to clients speed up insights from their information utilizing the AWS platform. He’s notably fascinated by the rising function that information streaming performs in driving innovation within the information analytics house. Exterior of his work at AWS, Austin enjoys watching and taking part in soccer, touring, and spending high quality time along with his household.







