DEV Community

Using Que instead of Sidekiq

Pete Keen on March 13, 2019

A project I've had on the back burner for quite awhile is my own little marketing automation tool. Not that existing tools like Drip or ConvertKit ...
Collapse
 
scottw profile image
Scott Watermasysk

I keep meaning to write up something about find_in_batches for this type of scenario.

I have tested quite a few things in this area, and the one which seems to work best is adding a select and pluck:

Contact.not_opted_out.select(:id).find_in_batches do |batch|
# call Sidekiq with batch.pluck(:id)
end

This lets you fully leverage ActiveRecord, but minimize an model creation/etc.

Collapse
 
zrail profile image
Pete Keen

Ah, good point! We actually use pluck in a piece of code very similar to this at work. Select and pluck seem like a powerful combo for this kind of thing. If I have time later I’ll add a benchmark for that.