Hacker News new | ask | show | jobs
by rubiquity 4122 days ago
I've done a setup similar to this in the past and really enjoy it. If you ever find yourself writing logic in your Resque/Sidekiq jobs that has to do with manually managing a data structure in Redis with regard to your jobs, your app is screaming for a language with better tools for modeling complex workflows.

A lot of people are hitting on the performance improvements (25 Sidekiq threads/workers versus 10k-100k+ Elixir/Erlang processes) but when I find myself doing this it's actually because my background process flows are really complex. The drastic increase in concurrency is just the cherry on top.

Background work is asynchronous by nature and often times you have dependencies between jobs, groups/batches jobs and also need robust error handling/recovery. This is where Elixir/Erlang really shines and using Actors & OTP to model these complex flows is the huge win in my experience. Sidekiq Pro offers support for batches which covers some of this, but ultimately Elixir/Erlang processes are just a huge improvement in modeling such systems.

A concrete example is sending off 10 jobs. When all 10 are done, move on to the next step. Each of these 10 jobs can also send data to the waiting step which it can then use as arguments. If any job should fail N times, cancel and rollback all of the jobs and try again. After the next step, split those 10 jobs into two groups of 5 and do those 5 sequentially. So on and so forth. Try doing this in Ruby. You'll likely have to manage your own data structures in Redis. In Elixir you just use GenServers and sometimes ets tables. It's all handled in the language itself, rather than external data stores.

Sidekiq is probably suitable for 90% of Ruby apps doing basic fire and forget and batching with Sidekiq Pro. But if your domain has seriously complicated background processing, use a tool more suited for that.