jordelver

jordelver

Is Broadway suitable for this task?

I’ve got a potential project that I think Broadway is well matched for, but I wanted to ask here for a sanity check :slight_smile:

The basic workflow is:

  1. Periodically fetch data from a JSON HTTP API
  2. Store / cache the data
  3. Convert data / munge data into another format
  4. Provide data over XML HTTP API

To begin with there will only be one endpoint, but in the future there will be many different sources. Each may have different schedules for fetching data.

If I was doing this in Ruby (my background) I would probably use some sort of background job to fetch and convert the data, and then serve the data via Rails.

One reason Broadway is attractive to me is because it has features like rate limiting, which I can see being useful as this scales.

Would you use Broadway for this?

Most Liked

sorentwo

sorentwo

Oban Core Team

I’m extremely biased, but I would use oban. It has periodic jobs, scheduled jobs, retries, resiliency, etc. Broadway is tailored for ingesting high throughout event streams.

akoutmos

akoutmos

Author of Build a Weather Station with Elixir and Nerves

I have written a few article/tutorials on Broadway and perhaps those can help inform your decision:
https://akoutmos.com/post/using-broadway/
https://akoutmos.com/post/broadway-rabbitmq-and-the-rise-of-elixir/
https://akoutmos.com/post/broadway-rabbitmq-and-the-rise-of-elixir-two/

I think some more information may be required to better answer your question:

  • How often are you fetching data from this JSON API?
  • Is it a singular piece of information that needs to be processed (i.e no benefit from concurrent processing)?
  • Do you require a message queue to persist messages across deployments of your service?

On the simple side of the spectrum, you could have a simple GenServer with a send_after to do everything that you outlined and just start that process up in your application.ex supervision tree. On the complex side of things, you could run RabbitMQ and Broadway to do your processing, but that depends on the answers to the Qs above :smiley:. Like others have mentioned, Oban is also a good tool for the requirements that you outlined.

chasers

chasers

I’ve used Broadway extensively. Have not used Oban.

You can use Broadway to poll you just put stuff in your own producer. So you can totally use Broadway here and it would be great.

With Broadway, you do need to understand the lifecycle of a process and your app if you want to make sure you get every event.

Oban is backed by a database so your state is always there. You don’t have to worry about deploys affecting processes, etc. You sacrifice some throughout for this.

So those are mostly your high level trade offs.

If you’re not super comfortable with gen servers I’d say use Oban. If you need all the throughput use Broadway.

Edit: I should maybe clarify. Broadway won’t do the polling for you. Make your poller and put the results in a queue somewhere (ETS probably) and the have your producer pull from that.

sorentwo

sorentwo

Oban Core Team

There is definitely a difference in throughput between batch ingesting SQS events and pulling from a transactional database. However, I think you’ll be limited by the actual job processing before the job processor’s throughput comes into play.

In my benchmarking Oban can process 15k no-op jobs per second on a single node—and batch processing is currently in the works which will increase that throughput significantly.

jordelver

jordelver

Thanks @chasers and @sorentwo for this interesting discussion. At the moment, I feel like I’d be more comfortable implementing a solution using Oban mainly because I understand the approach more clearly.

One thing that I like about the Oban is approach is observability. It seems to me that I can look at the state in the database and have a better idea of what is happening. I know Broadway has Telemetry hooks but I’m not sure about how to use those at the moment - that sounds like a totally new topic :wink:

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement