Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about consider use Redis stream structure to implement MQ #1144

Open
cw1427 opened this issue Oct 15, 2019 · 11 comments
Open

How about consider use Redis stream structure to implement MQ #1144

cw1427 opened this issue Oct 15, 2019 · 11 comments

Comments

@cw1427
Copy link

cw1427 commented Oct 15, 2019

It is not a issue, I just want to discuss about Redis stream consumer group to implement MQ would be more easier for the tasks queue implement. How about your opinion?

@selwin
Copy link
Collaborator

selwin commented Dec 8, 2019

I agree with you. I think Redis stream would be perfect for RQ. This is something we can consider for the future, probably a few years in when more systems ships with Redis 5.

@cw1427
Copy link
Author

cw1427 commented May 11, 2020

@selwin : Do we have plan to implement it? Cause Redis 6 GA is published, I'm so eager to have Steam feature to make RQ be more reliable and flexible.

@selwin
Copy link
Collaborator

selwin commented May 14, 2020

@cw1427 I think it's still a bit early to move to Redis streams because most server distros still ship with Redis 4.X by default.

You mentioned that adopting Streams will make RQ more reliable and flexible. I'm just curious as to what features you want to see in RQ and whether we can implement them without switching to Redis Streams.

As for myself, the most prominent benefit I see in switching to Streams would be the capability to XACK jobs so they're never dropped in cases where hard failures happen after popping the job from the queue.

@cw1427
Copy link
Author

cw1427 commented Jun 18, 2020

@selwin Yes the ack would be the most charming feature to make it be more reliable, and also the consumer group feature that Redis Stream has to make it flexible to deal with mulity kinds messages generation by different applications like "my Gerrit hook events, my Jenkins jobs trigger event, my JIRA actions and so on".

I would prefer RQ could be the general "pipe" like event bus to keep all of messages coming like steam and be consumed by customer clients by goups.

Here I fould a project shipped to Redis stream already. https://github.com/robinjoseph08/redisqueue But it is Go stack. I'm not good at customizing it than RQ.

@nkumar15
Copy link

redis stream is also useful for autoscaling cases in k8s cluster. Keda supports redis stream, if RQ supports redis streams it will be a neat and complete solution for a job queue based autoscaling functionality on K8s systems.

@selwin
Copy link
Collaborator

selwin commented Nov 29, 2022

This commit implements RQ's first use of Redis Stream to store data. What kind of use cases are we talking about here? If we were to implement or move something to Redis Stream, there has to be an upside.

@nkumar15
Copy link

nkumar15 commented Nov 29, 2022

thanks @selwin for quick response. The use case which I am seeing currently is to increase or decrease rq worker counts which are running in containers on basis of how many messages are present in redis queue.

The underlying infrastructure is Kubernetes for it and autoscaling is supported by KEDA

KEDA can monitor redis streams and increase underlying container counts as per set threshold.

If RQ supports redis streams then autoscaling of RQ workers can be easily done through KEDA

@selwin
Copy link
Collaborator

selwin commented Nov 29, 2022 via email

@nkumar15
Copy link

yes KEDA supports Redis list also

@essamgouda97
Copy link

essamgouda97 commented Feb 5, 2023

KEDA supports Redis lists but RQ uses redis sets which are not supported by KEDA.

Is that true or does rq use redis lists ? @selwin I tried this

127.0.0.1:6379> type rq:workers:TEST-Q
 set

@jheyer159
Copy link

jheyer159 commented Mar 16, 2023

Currently working on setting this up

KEDA supports Redis lists but RQ uses redis sets which are not supported by KEDA.

Is that true or does rq use redis lists ? @selwin I tried this

127.0.0.1:6379> type rq:workers:TEST-Q
 set

According to the following code pushing a job to the queue is using the Redis commands LPUSH and RPUSH

rq/rq/queue.py

Lines 451 to 454 in 60164c5

if at_front:
result = connection.lpush(self.key, job_id)
else:
result = connection.rpush(self.key, job_id)

which can be verified here as a list command.

EDIT 3/20/2023

after building out the PoC for this the main unknown was connecting the ScaledObject correctly which was discovered as follows.

triggers:
    - type: redis
      metadata:
        listName: rq:queue:my-queue-name   # <-- the queue name you're using - notice the prefix rq:queue

for example:

from rq import Queue
q = Queue('my-queue-name')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants