Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

AWS Serverless Error Handling With SQS as Event Source


Error Handling With AWS SQS as Event Source

If an Amazon SQS call fails or times out, the message is still visible.

The Lambda keeps retrying the message until it succeeds or the queue reaches its receive limit.

Setting up a dead-letter queue for rejected messages is a good practice.

Performance testing is required to find good solutions for your operations.


AWS SQS With Lambda

On Lambda functions, you can specify a timeout.

On SQS queues, you can define a visibility timeout.

You can also define the queue's batch size from one to ten messages per batch.

The batch size affects both your function and visibility timeout settings.

For quick processes, a larger batch size can increase efficiency.

For longer processes, a smaller batch size may be better.


Error Handling With AWS SQS as Event Source Video

W3schools.com collaborates with Amazon Web Services to deliver digital training content to our students.


How Error Handling With AWS SQS Works

If your function handles one message per 1 second, a batch of 10 messages will take 10 seconds to complete.

In that case, you could use 20 seconds timeout.

If a function handles one message per 2 minutes, the same batch will take 20 minutes to complete.

As Lambda's maximum timeout is 15 minutes, that batch would terminate without processing all messages.

Not processed messages would reappear in the queue.


Message Visibility

You must set the visibility timeout to provide your Lambda function enough time to complete a message batch.

When the function is throttled, you provide some buffer in the visibility timeout to accommodate Lambda call retries.

Setting your visibility timeout to 6 times the timeout of your function is recommended.


AWS Serverless Exercises

Test Yourself With Exercises

Exercise:

When will Lambda keep retrying to process a message?

1. Until it 
2. Untill the  reaches its limit

Start the Exercise


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.