Try Redis Cloud Essentials for Only $5/Month!

Learn More

Enhancing Redis Slow Log

Redis Slow Log is one of the best tools for debugging and tracing your Redis database, especially if you experience high latency and high CPU usage with Redis operations. This online discussion in a Redis DB group is just one of many examples that show how efficient Redis Slow Log is. Because Redis is based on a single threaded architecture, Redis Slow Log can be much more useful than slow log mechanisms of multi-threaded database systems such as MySQL Slow Query Log.

Unlike tools that include the software locking overhead which makes the debugging process very complex, Redis Slow Log is highly effective at showing the actual processing time of each slow command. As a provider of Redis Cloud, we use Redis Slow Log intensively for internal monitoring and to help our users solve latency issues related to their complex queries. And we often find ourselves struggling to understand the differences between two execution times of the same Redis command shown in the Slow Log – usually with complex commands such as ZUNIONSTORE, ZINTERSTORE, ZRANGEBYSCORE. Based on our experience, we thought the Redis community could benefit from adding the time complexity parameters for each command stored in the Slow Log. With this enhancement, we expect users to get a better understanding of their Redis DB operations, including differences between execution times of the same command and spikes in CPU usage. So without further ado, here’s (bold) what we’ve contributed for the Enhanced Redis Slow Log:

33) 1) (integer) 468359

 

2) (integer) 1358158701

3) (integer) 132912

4) Complexity info: N:48362,M:38687

5)1) “ZUNIONSTORE”

2) “AAA”

3) “5”

4) “BBB”

5) “CCC”

6) “DDD”

7) “EEE”

8) “FFF”

9) “WEIGHTS”

10) “1”

11) “1”

12) “1”

13) “1”

14) “1”

15) “AGGREGATE”

16) “MIN”

34) 1) (integer) 61701

2) (integer) 1354754379

3) (integer) 15217

4) Complexity info: N:886,M:885

5)    1) “ZREVRANGE”

2) “XYZ”

3) ”1”

4) ”1000”

5) “WITHSCORES”

35) 1) (integer) 61700

2) (integer) 1354754379

3) (integer) 16067

4) Complexity info: N:897,K:2,M:897

5)    1) “ZINTERSTORE”

2) “XYZ”

3) ”2”

4) ”YZX”

5) “ZXY”

 

For better understanding of the complexity, you may want to use the table below:

CommandValue of interestComplexity
LINSERTN – list lenO(N)
LREMN – list lenO(N)
LTRIMN – number of removed elemntsO(N)
PUBLISHN – number of channel subscribersM – number of subscribed patternsO(N+M)
PSUBSCRIBEN – number of patterns client is subscribed toargc – number of arguments passed to the commandO(argc*N)
PUNSUBSCRIBEN – number of patterns client is subscribed toM – total number of subscribed patternsargc – number of arguments passed to the commandO(argc*(N+M))
SDIFFN – total number of elements in all setsO(N)
SDIFFSTOREN – total number of elements in all setsO(N)
SINTERN – number of elements in smallest setargc – number of arguments passed to the commandO(argc*N)
SINTERSTOREN – number of elements in smallest setargc – number of arguments passed to the commandO(argc*N)
SMEMBERSN – number of elements in a setO(N)
SORTN – number of elements in the list/set/zsetM – number of elements in resultO(N+M*log(M))O(N) when no sorting
SUNIONN – total number of elements in all setsO(N)
SUNIONSTOREN – total number of elements in all setsO(N)
UNSUBSCRIBEN – total number of clients subscribed to all channelsO(N)
ZADDN – number of elements in the zsetO(log(N))
ZCOUNTN – number of elements in the zsetM – number of elements between min and maxO(log(N)+M)
ZINCRBYN – number of elements in the zsetO(log(N))
ZINTERSTOREN – number of elements in the smallest zsetK – number of zsetsM – number of elements in the results setO(N*K)+O(M*log(M))
ZRANGEN – number of elements in the zsetM – number of resultsO(log(N)+M)
ZRANGEBYSCOREN – number of elements in the zsetM – number of resultsO(log(N)+M)
ZRANKN – number of elements in the zsetO(log(N))
ZREMN – number of elements in the zsetargc – number of arguments passed to the commandO(argc*log(N))
ZREMRANGEBYRANKN – number of elements in the zsetM – number of elements removedO(log(N)+M)
ZREMRANGEBYSCOREN – number of elements in the zsetM – number of elements removedO(log(N)+M)
ZREVRANGEN – number of elements in the zsetM – number of resultsO(log(N)+M)
ZREVRANKN – number of elements in the zsetO(log(N))
ZUNIONSTOREN – sum of element counts of all zsetsM – element count of resultO(N)+O(M*log(M))

For those who are interested, this enhancement is part of our extended Redis 2.6. version and can be found here in our GitHub account.