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?

First Post!

axelson

axelson

Scenic Core Team

Disclaimer: I have never actually used broadway

I don’t think that broadway seems like a good fit since it won’t help you with this piece since the official and unofficial producers all pull from an event stream of sorts:

Currently we officially support three Broadway producers:

    Amazon SQS: Source - Guide
    Google Cloud Pub/Sub: Source - Guide
    RabbitMQ: Source - Guide

Although perhaps someone who’s actually used broadway could offer more guidance.

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.

Last Post!

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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New

We're in Beta

About us Mission Statement