本文介绍了Kafka + AWS Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将AWS Lambda与Apache Kafka集成?我想让使用者使用lambda函数.当使用者收到消息时,lambda函数将执行.
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.
推荐答案
阿拉法特继续讲到这一点.我们已经成功构建了使用AWS Lambdas从Kafka消费的基础架构.这是一些陷阱:
Continuing the point by Arafat. We have successfully built an infrastructure to consume from Kafka using AWS Lambdas. Here are some gotcha's:
- 在消费时,请确保在阅读时始终进行批处理和提交.
- 如果要将批次存储到s3,请确保清除文件描述符.
- 如果要将批次转发到另一个服务,请确保清除变量. AWS Lambda中的变量缓存可能会导致内存溢出.
- 一个好主意是检查从Lambda中的
context
对象还剩下多少时间,并给自己一些摆动的空间来处理您填充到使用者中的缓冲区(可能无法读取到文件)中的某些操作除非您致电close()
.
- 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 callclose()
.
我们正在使用Apache Airflow进行计划.我听说cloudwatch也可以做到这一点.
We are using Apache Airflow for scheduling. I hear cloudwatch can do that too.
这篇关于Kafka + AWS Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!