DEV Community

hoan-pham-duy
hoan-pham-duy

Posted on

Design the producer consumer problem using AWS

Hi everyone, today I would like to share how I'm using AWS to solve the producer consumer problem.
I got this case when I have to run a heavy background task that take a lot of time to run.
For example: User will send a request to generate images with filters the user choose and the tasks generate images with filters will take a lot of time to run.
Image description
Here is my explanation about my architecture:
Firstly, I need to build an API Gateway that can receive the user's request.
Secondly,every request from the user will be forwarded to Lambda Producer and the lambda will response that it received the user requests successfully
Thirstly, the producer will send message to SQS queue.
Finally, the SQS queue will trigger the Lambda Consumer each time it had new message. The Lambda Consumer will run background task and scale automatically based on number of message in the queue.

In my case, the Lambda Consumer will generate images with filters then uploads images back to S3 + send an email to user that it's done via AWS SNS.
Hope for your comments to see is there anything that I can do better.
Thank you!

Top comments (0)