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

Connection Pooling doesn't work as intended #687

Closed
Ashish-Bansal opened this issue Oct 27, 2023 · 1 comment
Closed

Connection Pooling doesn't work as intended #687

Ashish-Bansal opened this issue Oct 27, 2023 · 1 comment
Labels

Comments

@Ashish-Bansal
Copy link

Ashish-Bansal commented Oct 27, 2023

Description

I found that connection pooling doesn't work in django-redis package as intended if you use it as Cache Backend in Django.

Even if you configure it like -

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        # ...
        "OPTIONS": {
            "CONNECTION_POOL_KWARGS": {"max_connections": 100}
        }
    }
}

you would use a single connection for django.core.cache.cache operations.

You would actually use pooling, only if you interact with the Connection Pool manually by requesting connections.

Intended behavior

If we configure django_redis as mentioned in docs, we expect it to use multiple connections to the redis. This would be especially required in the concurrent world.

Stack trace

Here's code references -

I think pooling behaviour would be correct in Django's official implementation but Django's Redis backend may not be mature enough yet.

EDIT: Hm, I was wrong, it seems like pooling is handled at redis.client.Redis level. So, the implementation logic is same as Django's Redis backend. django_redis's implementation is correct!! I'll dig why connection pooling isn't working properly in my case.

@Ashish-Bansal
Copy link
Author

Implementation is correct, it probably works as intended, my bad!

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

No branches or pull requests

1 participant