1531139048.907426 "GET" "redisques:consumers:oli"
1531139048.907666 "EXPIRE" "redisques:consumers:oli" "20"
1531139048.907805 "GET" "redisques:consumers:oli"
1531139048.907939 "HEXISTS" "redisques:locks" "oli"
1531139048.908095 "LINDEX" "redisques:queues:oli" "0"
1531139048.908418 "ZADD" "redisques:queues" "1.531139048908E12" "oli"
1531139048.909548 "LPOP" "redisques:queues:oli"
1531139048.909864 "LLEN" "redisques:queues:oli"
Most of them are only executed after the previous one's response is received. RedisQues therefor suffers more from higher roundtrip times towards Redis server.
Situation
RedisQues executes the following sequence of eight Redis commands for dequeue of one message.
Example with a queue named "oli":
Most of them are only executed after the previous one's response is received. RedisQues therefor suffers more from higher roundtrip times towards Redis server.
Some ideas to improve this
EXPIRE redisques:consumers:oli 20from the dequeuing sequence. RedisQues already refreshes consumer registration independently with a timer. No need to repeat this while dequeuing.GET redisques:consumers:oli- Method RedisQues.consume(String queue) is only called for the current registered consumer - no need to check this here againLPOP redisques:queues:oliis only used to remove the head-of-queue after successful message delivery - Redis response is not used. Better useLTRIM ...queue 1 -1to remove head-of-queue without returning the message content.LLEN redisques:queues:olito check if queue is empty before starting the next consumption. Just do it, avoid this extra Redis command. Later, theLINDEX ...will detect the empty queue and stop processingIn other words: No need for
GET redisques:consumers:oliwhile we are in the consumption race. Perhaps we can have a look at myQueues to cross-check if we're still the consumer of this queue