What are the drawbacks of SQS poller which AWS Lambda removes?

时间秒杀一切 提交于 2019-12-25 18:54:07

问题


I have an architecture which looks like as follows:-

Multiple SNS -> (AWS Lambda or SQS with Poller)??? -> Dynamo Db

So, basically multiple SNS have subscribed to AWS Lambda or SQS with Poller and that thing pushes data to Dynamo Db.

But this ? thing do lot of transformation of message in between. So, now for such case, I can either use AWS Lambda or SQS with Poller. With AWS Lambda, I can do transformation in Lambda function and with SQS with Poller, I can do transformation in Poller. With AWS Lambda, I see one problem that code would become quite large as transformation is quite complex(has lot of rules), so I am thinking to use SQS. But before finalising on SQS, I wanted to know of the drawbacks of SQS which AWS Lambda removes?

Please help. Let me know if you need further information.


回答1:


Your question does not contain much detail, so I shall attempt to interpret your needs.

Option 1: SQS Polling

  • Information is sent to an Amazon SNS topic
  • An SQS queue is subscribed to the SNS topic
  • An application running on Amazon EC2 instance(s) regularly poll the SQS queue to ask for a message
  • If a message is available, the data in the message is transformed and saved to an Amazon DynamoDB table

This approach is good if the transformation takes a long time to process. The number of EC2 instances can be scaled based upon the amount of work in the queue. Multiple messages can be received at the same time. It is a traditional message-based approach.

Option 2: Using Lambda

  • Information is sent to an Amazon SNS topic
  • An AWS Lambda function is subscribed to the SNS topic
  • A Lambda function is invoked when a message is sent to the SNS topic
  • The Lambda function transforms the data in the message and saves it to an Amazon DynamoDB table

AWS Lambda functions are limited to five minutes of execution time, so this approach will only work if the transformation process can be completed within that timeframe.

No servers are required because Lambda will automatically run multiple functions in parallel. When no work is to be performed, no Lambda functions execute and there is no compute charge.

Between the two options, using AWS Lambda is much more efficient and scalable but it might vary depending upon your specific workload.




回答2:


We can now use SQS messages to trigger AWS Lambda Functions.

28 JUN 2018: AWS Lambda Adds Amazon Simple Queue Service to Supported Event Sources

Moreover, no longer required to run a message polling service or create an SQS to SNS mapping. AWS Serverless Model supports a new event source as following:

Type: SQS
 PropertiesProperties:
  QueueQueue: arn:aws:sqs:us-west-2:213455678901:test-queue arn:aws:sqs:us-west-2:123791293
  BatchSize: 10

AWS Console also support:

Further details:
https://aws.amazon.com/blogs/aws/aws-lambda-adds-amazon-simple-queue-service-to-supported-event-sources/
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html



来源:https://stackoverflow.com/questions/44469186/what-are-the-drawbacks-of-sqs-poller-which-aws-lambda-removes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!