Kafka + AWS lambda

2019-03-13 17:24发布

Is it possible to integrate AWS Lambda with Apache Kafka ? I want to put a consumer in a lambda function. When a consumer receive a message the lambda function execute.

4条回答
孤傲高冷的网名
2楼-- · 2019-03-13 17:33

There is a community-provided Kafka Connector for AWS Lambda. This solution would require you to run the connector somewhere such as EC2 or ECS.

查看更多
太酷不给撩
3楼-- · 2019-03-13 17:35

Here is AWS article on scheduled lambdas.

Given your Kafka installation will be running in a VPC, best practise is to configure your Lambda to run within the VPC as well - this will simplify the security group configuration for the EC2 instances running Kafka.

Here is the AWS blog article on configuring Lambdas to run in a VPC.

查看更多
相关推荐>>
4楼-- · 2019-03-13 17:47

Continuing the point by Arafat. We have successfully built an infrastructure to consume from Kafka using AWS Lambdas. Here are some gotcha's:

  • Make sure to consistently batch and commit while reading when consuming.
  • If you are storing the batches to s3, make sure to clean your file descriptors.
  • If you are forwarding the batches to another service make sure to clean the variables. Variable caching in AWS Lambda might result in memory overflows.
  • A good idea is to check how much time you have left while from the context object in the Lambda and give yourself some wiggle room to do something with the buffer you populated in your consumer which might not be read to a file unless you call close().

We are using Apache Airflow for scheduling. I hear cloudwatch can do that too.

查看更多
叼着烟拽天下
5楼-- · 2019-03-13 17:49

Yes it is very much possible to have a Kafka consumer in AWS Lambda function.

However note that you would not be able to invoke the lambda using some sort of notification. You will rather have to poll the Kafka topic. And the easiest way can be to use a Scheduled Lambda

查看更多
登录 后发表回答