AWS API Gateway默认响应和触发AWS Lambda [英] AWS API Gateway default response and Trigger AWS Lambda

查看:299
本文介绍了AWS API Gateway默认响应和触发AWS Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用AWS API Gateway和AWS Lambda来尝试无服务器架构.一直在浏览博客和AWS文档.已经尝试了示例GET/POST.但是,我有以下要求才能从我的自定义应用程序中跟踪用户事件

I have been experimenting with AWS API Gateway and AWS Lambda to try out a serverless architecture. Have been going through blogs and AWS documentation. Have tried out sample GET/POST. But, I have the following requirement w.r.t tracking user events from my custom application

  • 事件从我的应用程序发布到API端点
    • 我希望API用自定义响应进行响应(说{'fine'}) (确认已收到请求)
    • Events are posted from my application to API end point
      • I wanted the API to respond back with a custom response (Say {'fine'}) (acknowledging that the request has been received)

      根据文档,我了解, a)我可以将事件发布到API端点 b)在GET/POST上触发AWS Lambda函数 -从AWS Lambda函数响应API请求

      As per the documentation, I understand, a) I can post events to API end point b) On GET/POST trigger an AWS Lambda Function - Respond back from AWS Lambda function to API request

      我想更改以上内容并将其修改为 a)将事件发布到API端点 a.0)回复确认已收到请求[说{'fine'}] b)触发AWS Lambda函数以处理事件有效负载

      I wanted to change the above and modify it to a) Post events to API end point a.0) Respond back acknowledging that request is received [Say {'fine'} ] b) Trigger AWS Lambda function to process the event payload

      请分享有关如何实现相同建议的建议.

      Please share across suggestions on how to achieve the same.

      推荐答案

      许多客户使用的另一个异步模型:

      Another asynchronous model many customers have used:

      1. 设置配置为使用您的Kinesis流.
      1. Set up an API configured to send requests to Amazon Kinesis. This API could acknowledge the request.
      2. Set up AWS Lambda to consume your Kinesis stream.

      此设置对于高工作负载的API具有一些优势,因为可以对从Kinesis流中获取的内容进行批处理,并且不需要对API网关限制和Lambda限制进行一对一的缩放.

      This setup has some advantages for high workload APIs as fetches from the Kinesis stream can be batched and don't require a 1-to-1 scaling of both your API Gateway limits and Lambda limits.

      更新

      要回答有关可伸缩性的问题:

      To answer your questions about scalability:

      运动力

      Kinesis通过在流中添加所谓的碎片"来扩展规模.每个分片根据分区键处理一部分流量.每个分片最多可扩展至1000 rps或1MBps(请参阅限制).即使使用较低的默认25个分片,使用均匀分布的分区密钥,也可以支持高达25,000 rps或25MBps.

      Kinesis scales by adding what it calls "shards" to the stream. Each shard handles a portion of your traffic, based on a partition key. Each shard scales up to 1000 rps or 1MBps (see limits). Even with the lower default 25 shards, this would support up to 25,000 rps or 25MBps with an evenly distributed partition key.

      API网关

      API网关的默认帐户级别限制为500 rps,但是可以通过请求增加限制来轻松扩展.我们有生产中的客户正在使用超出您当前建议规模的限制的服务.

      API Gateway has a default account level limit of 500 rps, but this can easily be extended by requesting a limit increase. We have customers in production that are using the service at limits above your current suggested scale.

      这篇关于AWS API Gateway默认响应和触发AWS Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆