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

Add support for Redis Cluster #250

Closed
wants to merge 13 commits into from
Closed

Add support for Redis Cluster #250

wants to merge 13 commits into from

Conversation

maeln
Copy link
Contributor

@maeln maeln commented Dec 21, 2023

Hello!

This PR aim to add the support for Redis Cluster: https://redis.io/docs/management/scaling/
This is different than Redis Sentinel, which is already supported.

Since this is a bit more complicated to use than a normal redis instance, I try to put more complete example in the documentation.
Redis Cluster is supported since version 4.1 of redis-py, so it should be pretty stable.

Open to feedback :)

@zzzeek
Copy link
Member

zzzeek commented Dec 21, 2023

hey there -

how would this be tested? Are there directives you can add to tox.ini to run redis in this mode?

@maeln
Copy link
Contributor Author

maeln commented Dec 21, 2023

Hi,
It should be testable by creating a redis cluster locally, using for example the cli in the redis documentation: https://redis.io/docs/management/scaling/#create-a-redis-cluster

I tested using one redis cluster i had laying around and it was working.
I will try to to write a small test procedure tomorow and I will look if anything is needed for the tox file

EDIT: I see that it is not the first time :p #135

@zzzeek
Copy link
Member

zzzeek commented Dec 21, 2023

if you can get it into the tox file then we can just test on CI

@maeln
Copy link
Contributor Author

maeln commented Dec 22, 2023

To make it work, I need to update pifpaf so that they can spawn a redis-cluster. I am working on it, and i will submit a patch to them

@maeln
Copy link
Contributor Author

maeln commented Dec 22, 2023

Made a PR to pifpaf to add Redis Cluster support: jd/pifpaf#163

@zzzeek
Copy link
Member

zzzeek commented Dec 22, 2023

wow, thanks for that effort. the pifpaf project seems kind of dead lately so hopefully someone can accept that PR. otherwise we might have to go without CI testing here for now

@zzzeek zzzeek requested a review from sqla-tester December 22, 2023 13:40
Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 6875e4e of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

New Gerrit review created for change 6875e4e: https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/5033

@maeln
Copy link
Contributor Author

maeln commented Dec 22, 2023

Seems like I have a few formatting issue to fix. I will take care of it soon

@zzzeek
Copy link
Member

zzzeek commented Dec 22, 2023

OK, can you also add a changelog file? see a commit like 074cb77 to see an example of what this file looks like. this would be :tags: feature, redis and :tickets: 250 since there is no separate issue here. feel free to credit yourself in the changelog.

@maeln
Copy link
Contributor Author

maeln commented Dec 22, 2023

Will do!

@maeln
Copy link
Contributor Author

maeln commented Dec 22, 2023

I wrote a changelog, it is a bit dry but I didn't know what more to say, and I also check the generated doc + run tox. Everything seems fine :) . Hopefully pifpaf merge the PR and we can add some tests. I was in contact with jd a few months ago on a completely separate thing, so maybe I can try to send him a quick mail, but I think founding his company as kept him quite busy, so we will see.

@zzzeek
Copy link
Member

zzzeek commented Dec 22, 2023

oh is that what he did huh.

@zzzeek zzzeek requested a review from sqla-tester December 22, 2023 15:08
Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision d112f02 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

Patchset d112f02 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/5033

@zzzeek
Copy link
Member

zzzeek commented Dec 22, 2023

either way, this is a totally new backend that wont break anything, it's only a few lines of startup code, and im sure you're using it on your end so it's not too controversial to just merge it

@CaselIT
Copy link
Member

CaselIT commented Dec 22, 2023

seem we could spin up a docker image with a redis cluster https://github.com/Grokzen/docker-redis-cluster

@maeln
Copy link
Contributor Author

maeln commented Dec 26, 2023

If you want to test locally, you should be able to spawn a working redis cluster with the pifpaf fork I made : https://github.com/maeln/pifpaf

Using the command :

python -m pifpaf run redis --cluster

@zzzeek
Copy link
Member

zzzeek commented Feb 5, 2024

any news on this?

@maeln
Copy link
Contributor Author

maeln commented Feb 9, 2024

Hello! Sadly, no news on the pifpaf side of things :/ . I don't know if there is any other way forward if we want to merge it

@zzzeek
Copy link
Member

zzzeek commented Feb 9, 2024

well we'd just merge it. you've tested this on your end in a real program right?

also @CaselIT we might need to find an alternative to pifpaf, maybe home roll

@CaselIT
Copy link
Member

CaselIT commented Feb 9, 2024

maybe home roll

zifzaf? 😨

are there no alternative?

@CaselIT
Copy link
Member

CaselIT commented Feb 9, 2024

Also not sure what's the state of pifpaf, but it seems it's still active, meaning there were commits to it recently (last month)

seem we could spin up a docker image with a redis cluster https://github.com/Grokzen/docker-redis-cluster

would this be an option mike?

@zzzeek
Copy link
Member

zzzeek commented Feb 9, 2024

I would assume everyone has shell scripts that run containers these days

@sqla-tester
Copy link
Collaborator

Michael Bayer (zzzeek) wrote:

We can't get a CI run as pifpaf does not support the backend, however this is a totally new add that does not affect any existing code so we can just merge this.

View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/5033

@sqla-tester
Copy link
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/5033 has been merged. Congratulations! :)

@maeln
Copy link
Contributor Author

maeln commented Feb 19, 2024

Hi! Sorry for the delay, life got in the way ...

@zzzeek Yes, I tested it in a real product using a simple local setup (spawning manually 3 redis server in cluster mode) and the Scaleway redis cluster managed service. I also tested on a more synthetic setup and so far everything was working great.

Thank you for the merge :) . Things are a bit complicated for me these days, but when it settles down, I will try to go back to the pif paf PR to see if I can get it to be merged

@zzzeek zzzeek mentioned this pull request Jan 28, 2025
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

Successfully merging this pull request may close these issues.

4 participants