Diagram 6 of 12

Asynchronous processing with SQS

Requests are accepted fast and processed later. API Gateway puts each message in an SQS queue, Lambda consumes it at its own pace, stores the result in DynamoDB and publishes notifications with SNS. Messages that keep failing go to a dead-letter queue.

Amazon API GatewayAmazon SQSAWS LambdaAmazon DynamoDBAmazon SNSDead-letter queue

Diagram

Diagram 6: asynchronous processing (API Gateway + SQS + Lambda)AWS CloudUsersAPIAmazon APIGatewaySQSAmazon SQS(queue)λAWS Lambda(processes)DDBAmazon DynamoDB(results)SNSAmazon SNS(notifications)DLQDead-letterqueue (DLQ)1234561. The client sends the request to Amazon API Gateway.2. API Gateway puts the message in SQS and responds without waiting for processing.3. Lambda consumes messages from the queue and runs the business logic.4. Lambda stores the result in Amazon DynamoDB.5. Lambda publishes an event to Amazon SNS to notify subscribers.6. Messages that fail repeatedly are moved to the dead-letter queue (DLQ).

Comments

Information flow

  1. Amazon API Gateway

    The client sends the request to API Gateway.

  2. Amazon SQS

    API Gateway puts the message in the queue and responds without waiting for processing.

  3. AWS Lambda

    Lambda consumes messages from the queue in batches and runs the business logic.

  4. Amazon DynamoDB

    Lambda stores the result in DynamoDB.

  5. Amazon SNS

    Lambda publishes an event to SNS to notify subscribers, such as email or HTTP endpoints.

  6. Dead-letter queue

    If a message fails more times than allowed, SQS moves it to the DLQ for review.