Is RedisCluster thread-safe? #452
-
If used inside of a web-app should I be creating a new RedisCluster instance per-thread? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@davidanthonygardner The best way to think of this is that if you have an example where you use the plain redis-py version and Redis class instance, this library is built to be a drop-in-replacement where you should just be able to replace The whole point of having it threadsafe is really difficult to test and most of the time users have to test it out and find the issues in production. From my own experience, the only place where thread saftey issues have occured so far in this repo over time is around the connection pool and pipelines. So my suggestion is that you have to test and ensure that your usage of this code works in your situation, i can't say for sure that it will work threadsafe in every possible situation, i simply do not know. To take a practical example from a web-app that i know about. In django you create the RedisCluster object at the level of the settings file and that file and object instance is shared among all threads in that instance you run. Since i do not know how this lib works with other web frameworks like Flask, Pyramid etc, i can't say for them tho. And i can say that i never personally had any issues using this in Django at least. |
Beta Was this translation helpful? Give feedback.
@davidanthonygardner The best way to think of this is that if you have an example where you use the plain redis-py version and Redis class instance, this library is built to be a drop-in-replacement where you should just be able to replace
Redis
withRedisCluster
and it should work out exactly the same with the same properties and features etc.The whole point of having it threadsafe is really difficult to test and most of the time users have to test it out and find the issues in production. From my own experience, the only place where thread saftey issues have occured so far in this repo over time is around the connection pool and pipelines. So my suggestion is that you have to test and …