Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Amazon SQS the right choice here? Rails performance issue [closed]

I'm close to releasing a rails app with the common networking features (messaging, wall, etc.). I want to use some kind of background processing (most likely Bj) for off-loading tasks from the request/response cycle.

This would happen when users invite friends via email to join and for email notifications.

I'm not sure if I should just drop these invites and notifications in my Database, using a model and then just process it with a worker process every x minutes or if I should go for Amazon SQS, storing the messages and invites there and let my worker retrieve it from Amazon SQS for processing (sending the invites / notifications).

The Amazon approach would get load off my Database but I guess it is slower to retrieve messages from there.

What do you think?

like image 309
Ole Spaarmann Avatar asked May 23 '09 13:05

Ole Spaarmann


People also ask

Is AWS SQS reliable?

Amazon SQS offers a reliable, highly-scalable hosted queue for storing messages as they travel between applications or microservices. It moves data between distributed application components and helps you decouple these components.

Why is SQS an appropriate service for this scenario?

Why is SQS an appropriate service for this scenario? SQS guarantees the order of the messages. SQS synchronously provides transcoding output. SQS checks the health of the worker instances.

Which is better SQS or SNS?

With SQS, messages are delivered through a long polling (pull) mechanism, while SNS uses a push mechanism to immediately deliver messages to subscribed endpoints. SNS is typically used for applications that need realtime notifications, while SQS is more suited for message processing use cases.


1 Answers

Your title states that you have a Rails performance issue, but do you know this for certain? From the rest of your question it sounds like you're trying to anticipate a possible future performance issue. The only way to deal sensibly with performance issues is to get your application into the wild and profile it. Doing so will give you empirical data as to what the real performance issues are.

Given that Amazon SQS isn't free and the fact that using it will almost certainly add complexity to your application, I would migrate to it if and when database load becomes a problem. Don't try to second guess problems before they arise, because you'll find that you'll likely face different problems when your app goes live, some of which you probably haven't considered.

The main point is that you've already decided to use background processing, which is the correct decision, given that any sort of processing that isn't instantaneous doesn't belong within the Rails' request/response cycle, as it blocks that Rails process. You can always scale with Amazon later if you need to.

like image 153
John Topley Avatar answered Oct 04 '22 02:10

John Topley