You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for creating so nice library and amazing documentation.
Setup
I'm running Node.js Web application in Kubernetes. Depends on traffic I have 8-30 pods. I do not have Redis Cluster and have only one redis client in code. I'm using redlock (5.0.0-beta.2). So my setup looks like this.
constredisClient=newRedis('my-redis-url',{enableOfflineQueue: false,// Do not collect commands in pending queue. Throw exception, if redis not available.maxRetriesPerRequest: 0,// Do not retry command. Throw exception, if redis not available.});constredlock=newRedlock([redisClient],{retryCount: 0,// One attempt or throw exceptionautomaticExtensionThreshold: 5000,})
I need lock to select only one (primary) pod to execute background job which updates cache. All other pods(secondary) retry to acquire lock, if failed then sleep for one minute. I'm using this approach:
awaitredlock.using(['my-backgroung-job-lock'],15000,asyncsignal=>{// business code when lock is acquired}
Investigation
All good on primary pod. I have 6 evalsha requests per minute (60000/ (15000-5000)) = 6
But on secondary pods amount of evalsha requests is looks to big. I expect only one request per pod, but have two. I've investigated code and found this part.
Hi !
First of all, thank you for creating so nice library and amazing documentation.
Setup
I'm running Node.js Web application in Kubernetes. Depends on traffic I have 8-30 pods. I do not have Redis Cluster and have only one redis client in code. I'm using
redlock
(5.0.0-beta.2). So my setup looks like this.I need lock to select only one (primary) pod to execute background job which updates cache. All other pods(secondary) retry to acquire lock, if failed then sleep for one minute. I'm using this approach:
Investigation
All good on primary pod. I have 6
evalsha
requests per minute (60000/ (15000-5000)) = 6But on secondary pods amount of
evalsha
requests is looks to big. I expect only one request per pod, but have two. I've investigated code and found this part.node-redlock/src/index.ts
Lines 330 to 333 in 5138813
This means that each secondary pod executes
ACQUIRE_SCRIPT
- that is expected. But if it fails, thenRELEASE_SCRIPT
executed unconditionally.Proposal
We can improve performance (decrease amount of requests to Redis) and do not execute
RELEASE_SCRIPT
when:ACQUIRE_SCRIPT
returns zeroThe text was updated successfully, but these errors were encountered: