英文:
One endpoint, multiple lambdas?
问题
我们每天24小时通过端点接收大量数据,端点之后有一个Lambda函数执行其任务,然后将数据发送到S3。但我们希望有另一个Lambda函数也能获取负载并对这些数据进行处理。如何实现?
或者如果我想实现类似的结果,有什么变通方法?
目前,我们正在使用一种愚蠢的方法,在一个Lambda内部调用另一个Lambda来将数据发送到那个Lambda...
英文:
We receive large amount of data 24hour by endpoint and after the endpoint, there is a lambda function doing it's job the send data to s3. But we want other lambda that also can get the payload and doing something with this data. How to do that?
Or if I want to achieve similar result, what is the circumvent?
Currently, we are doing some stupid method, inside one lambda call other lambda to send lambda to that lambda...
答案1
得分: 2
你目前的方法,“一个Lambda函数调用另一个Lambda函数”,是可以的,但这里有一个替代方法:
- API Gateway 调用 AWS Lambda函数
- 该Lambda函数发送消息到 Amazon SNS主题
- Lambda函数退出
然后,为您想要在消息上执行的每个处理过程创建一个单独的Lambda函数,并订阅该Lambda函数到SNS主题。
结果:
- 第一个Lambda函数引发对其他Lambda函数的 “扇出”
- 所有Lambda函数可以并行处理消息
- 通过简单地控制SNS主题上的订阅,可以添加/移除Lambda函数
英文:
Your current method of "one Lambda function calling another Lambda function" is fine, but here's an alternative:
- API Gateway invokes the AWS Lambda function
- That Lambda function sends a message to an Amazon SNS Topic
- Lambda function exits
Then, create a separate Lambda function for each process you want to perform on the message and subscribe that Lambda function to the SNS Topic.
Result:
- First Lambda function causes a 'fan out' to the other Lambda functions
- All the Lambda functions can process the messages in parallel
- Add/remove Lambda functions by simply controlling the subscriptions on the SNS Topic
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论