Hacker News new | ask | show | jobs
by ankurpatel 4122 days ago
Why are you adding an extra level of abstraction in between Rails and Sidekiq? Why not just have Rails push to redis queue and elixir process finishes the job of sending email or doing what it has to do. Why have Sidekiq run at all? It seems adding multiple layers as such will make it harder to understand, debug and maintain in future.

EDIT: Also your example of polling on Redis queue using elixir is very inefficient and makes your article not so credible in my eyes or eyes of other good software architects. Redis is meant for pub sub and not polling.

2 comments

Redis has blocking list primitives which you can use to build an efficient queue (push and pop in O(1)), if you look at the code you'll see he's using brpop
I agree but there is no need to poll. Polling is a poor mans solution in a world where you can have persistent connection and get push notification of when a new item is added to the queue and there is no need to throttle for 10 seconds before polling again.
A listening pattern still has to poll on boot for unprocessed jobs.
I think it makes some sense to use the Sidekiq client, because it does a lot of the tedious work of getting data into redis in a well-defined and battle-tested fashion. But certainly it doesn't make sense to run the Sidekiq daemon in this configuration.