简体   繁体   English

在这个用例中,Lambda 是否需要 SQS?

[英]Is an SQS needed with a Lambda in this use case?

I'm trying to build a flow that allows a user to enter data and it's being stored in RDS.我正在尝试构建一个允许用户输入数据并将其存储在 RDS 中的流程。 My question is do I need to go from USER -> SQS -> Lambda -> RDS to or is it better to go straight from USER -> Lambda -> RDS which skips the queue entirely. My question is do I need to go from USER -> SQS -> Lambda -> RDS to or is it better to go straight from USER -> Lambda -> RDS which skips the queue entirely. Are there going to be scalability issues with the latter?后者是否存在可扩展性问题?

I do like that the SQS can retry a large number of times to guarantee the data, but is there a similar way to retry with a lambda alone?我确实喜欢 SQS 可以多次重试以保证数据,但是有没有类似的方法可以单独使用 lambda 进行重试? It's important that all of the data is stored and done so in a timely manner.重要的是要及时存储和完成所有数据。 I'm struggling to see the tradeoffs of the two scenarios.我很难看到这两种情况的权衡。

If anyone has any input on the situation, that would be amazing.如果有人对这种情况有任何意见,那就太棒了。

Are there going to be scalability issues with the latter?后者是否存在可扩展性问题?

It depends on multiple metrics including traffic, spikes, size of the database, rpm etc.它取决于多个指标,包括流量、峰值、数据库大小、rpm 等。

Putting SQS before lambda provides you to manage number of database queries in t time according to your needs.将 SQS 放在 lambda 之前,您可以根据需要在 t 时间内管理数据库查询的数量。 It is a "queue" and you are consuming that queue.这是一个“队列”,您正在使用该队列。 In some business cases it may not be useful(banking transactions etc) but in some cases(analytic calculations) it may be helpful.在某些业务案例中它可能没有用(银行交易等),但在某些情况下(分析计算)它可能会有所帮助。 Instead of making a single insert whenever lambda is invoked, you can set batch size and insert in batch (10 records at once) which reduces the number of queries.每次调用 lambda 时,无需进行单个插入,而是可以设置batch size批量插入(一次 10 条记录),从而减少查询数量。

Also you can define dead letter queue to push your problematic data(couldn't make it to database).您还可以定义dead letter queue来推送有问题的数据(无法将其发送到数据库)。 It will be another queue that you to check later to identify problematic inputs.这将是您稍后检查以识别有问题的输入的另一个队列。 The document can be found here该文件可以在这里找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM