rump13

rump13

Hello everyone! I’m new to Elixir and this is my first post here.

I’m currently developing a web application that requires processing of messages from a single AWS SQS queue. The queue contains two types of messages: fast messages that need to be processed quickly, and slow messages that can wait. The fast messages make up 95% of the queue, while the slow messages are only 5%. Processing the fast messages is simple: I just need to extract some data from the notifications and store them in a database. On the other hand, processing the slow messages requires a lot of computation and IO resources, but it doesn’t need to be done in almost-realtime.

Currently, I’m using BroadwaySQS.Producer to receive messages from AWS SQS and process the fast messages. For the slow messages, I plan to receive them in the same Broadway pipeline and create a job for each one using Oban. This way, the slow messages can be delegated to Oban as jobs that can be processed later. I’ll be using the free version of Oban.

Do you see any issues with integrating Broadway pipelines with Oban jobs? Or is it possible to solve this problem using only Broadway?

Happy coding! :slight_smile:

Showing Posts 1 to 7

kanishka

kanishka

My first instinct is why bring in Oban, if you can use tasks and let deletion from sqs queue to determine whether something is complete or needs a retry. I am unsure if my assumptions about sqs queues and deletion are correct.

rump13

rump13 OP

I want to ensure that even if the whole app crashes or the server needs a reboot, those slow messages/jobs don’t get lost. However, I also want to remove them from the queue quickly because fast messages are altering the database and displaying content on the user interface (using Phoenix/LiveView).

Additionally, I want to control how many slow messages I’m dealing with at any given time. For instance, I may want to process just one slow message at a time. But, I’m not sure how to accomplish all of this using only Broadway.

sorentwo

sorentwo

Oban Core Team

@rump13 your plan seems sound to me. Broadway is meant for ingesting messages with back pressure, not as a general purpose background job system.

@kanishka this article explains why you’d want to use Oban instead of plain tasks: Oban Starts Where Tasks End · Oban Pro

kanishka

kanishka

I have read that article. What seems strange to me here is using both SQS and Oban. I would use one or the other.

kanishka

kanishka

app crashes

" Note however, that Broadway does not provide any sort of retries out of the box. This is left completely as a responsibility of the producer. For instance, if you are using Amazon SQS, the default behaviour is to retry unacknowledged messages after a user-defined timeout. If you don’t want unacknowledged messages to be retried, is your responsibility to configure a dead-letter queue as target for those messages."

I think that would cover the crash case?

control how many slow messages

I don’t know broadway well, but I assume there is a way to use different pools of workers and set sizes on the pools

tmartin8080

tmartin8080

You could likely use a separate SQS queue and broadway pipeline to process fast/slow messages.

  • SQS: fast.queue, slow.queue
  • Broadway: FastPipeline, SlowPipeline

Then either publish messages from current publisher or from FastBroadway as it comes across a “slow” message.

If it helps, you can control the concurrency for processors etc.

tmartin8080

tmartin8080

those slow messages/jobs don’t get lost

Might also be worth mentioning that Broadway handles exceptions during processing and passes any failed messages to handle_failed/2 so you can log/alert/cleanup/re-publish etc. SQS messages won’t be deleted until they’re acknowledged so there’s a low chance of them getting lost.

We use RabbitMQ with Broadway and create dynamic queues for retries and exponential backoff. It seems like SQS supports delayed queues but haven’t used them.

Oban is definitely an option (and an amazing tool thanks @sorentwo :heart:) but might be worth exploring what’s possible with your current setup.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews