is executing lua script considered as a blocking use case to use connection pooling? #2131
Replies: 5 comments
-
@mp911de in the case of redis cluster client, do we need to use connection pooling in that case? |
Beta Was this translation helpful? Give feedback.
-
Lua on its own isn't really blocking. However, it depends on what the Lua script is calling, and whether you're using blocking calls within the Lua script. |
Beta Was this translation helpful? Give feedback.
-
Let's say we need to trim down some list atomically, which can take linear time complexity in worst case scenario. For this we write a lua script which runs atomically on redis. So, calling this operation from the connection where we issue GET,SET etc commands won't be good right as it may block the entire pipeline for that connection? Ideally for commands which take time should be issued from a separate connection, if they are only run once, and then maybe this connection should be closed properly. |
Beta Was this translation helpful? Give feedback.
-
But, a badly written Lua script can halt multiple clients whether you run it from a different Redis connection or even another client issuing eval command. |
Beta Was this translation helpful? Give feedback.
-
You're in charge of dispatching commands onto connections. If you have to run a costly Lua script, then it is better to use a dedicated connection to not harm other commands that need to return quickly. It's always a balance between resource usage and performance. |
Beta Was this translation helpful? Give feedback.
-
From the docs, it is saying that for operations like
BLPOP
or transaction cases, we should not share the connection with multiple threads, otherwise there would be some side effect. I am wondering what are the side effects? And is executing lua script also a use case to use connection pooling?Beta Was this translation helpful? Give feedback.
All reactions