Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS two SQS queues sending to one worker

I have an application which sends emails and performs file uploads (and image resizing). Both of these services are not used too often and are quite light.

I'm already using a SQS queue to send messages (email to/subject/body) to a worker running a Sinatra app calling the SES API, this is running fine. My question is: is it possible to send file upload messages to that same worker too? This could be on a different queue maybe.

It seems pretty wasteful to have two ec2 instances sitting there, (for the most part), doing nothing.

PS: I'm using elastic beanstalk

like image 397
Mark Kenny Avatar asked Jul 02 '14 11:07

Mark Kenny


1 Answers

It would be better to introduce a attribute TYPE in your message. Message TYPE could be EMAIL/FILEUPLOAD. Based on the attribute TYPE, the worker can call the respective service with the message.

With the above approach, you would be able to process messsages with one worker & one queue. You can auto-scale the server too and there will be no problems with processing messages with multiple workers.

like image 169
Santhosh S Avatar answered Sep 27 '22 21:09

Santhosh S