25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Redis Slow Log

by | Mar 13, 2021

Need to know about Redis Slow Log? We can help you.

Recently we had a customer who experienced high latency and high CPU usage with Redis operations. In such a case, Redis Slow Log is one of the best tools to debug and trace the Redis database.

Since Redis base on a single-threaded architecture, Redis Slow Log is much more useful than MySQL Slow Query Log.

As part of our Server Management Services, we assist our customers with several Redis queries.

Today, let us discuss Redis Slow Log.

 

What is Redis slow log?

It is a system to log queries that exceeded a specified execution time. This does not include I/O operations like talk with the client, reply, and so forth, but the time to actually execute the command.

SLOWLOG subcommand [argument]

This command is available since 2.2.12 and we use it in order to read and reset the Redis slow queries log.

 

How to setup slow log parameters?

We can configure the slow log with two parameters:

  • slowlog-log-slower-than

This tells Redis what is the execution time, in microseconds, to exceed in order for the command to log.

  • slowlog-max-len

It is the length of the slow log. The minimum value is zero. When a new command logs and the slow log is already at its maximum length, it removes the oldest one from the queue of logged commands in order to make space.

We can edit, redis.conf to do this configuration, or use the CONFIG GET and CONFIG SET commands while the server run.

In addition, it is highly effective at showing the actual processing time of each command.

 

How to read Slow Log?

The slow log accumulates in memory. This makes it remarkably fast that we can enable the logging of all the commands with a minor performance hit.

Generally, we use the SLOWLOG GET command to read the slow log which returns every entry in the slow log.

It is possible to return only the N most recent entries passing an additional argument to the command (for instance SLOWLOG GET 10).

In addition, our Support Techs suggest having a recent version of redis-cli in order to read the slow log output.

Output format
redis 127.0.0.1:6379> slowlog get 2
1) 1) (integer) 14
2) (integer) 1309448221
3) (integer) 15
4) 1) “ping”
2) 1) (integer) 13
2) (integer) 1309448128
3) (integer) 30
4) 1) “slowlog”
2) “get”
3) “100”

There are also optional fields emitted only by Redis 4.0 or greater:

5) “127.0.0.1:58217”
6) “worker-123”

Every entry composes of four (or six) fields:

  • A unique progressive identifier for every slow log entry.
  • The unix timestamp at which the logged command process.
  • The amount of time for the execution, in microseconds.
  • The array composing the arguments of the command.
  • Client IP address and port (4.0 only).
  • Client name if set via the CLIENT SETNAME command (4.0 only).

We can use the entry’s unique ID in order to avoid processing slow log entries multiple times.

The ID is never reset in the course of the Redis server execution. However, a server restart can reset it.

In addition, it is possible to get the length of the slow log using the command SLOWLOG LEN.

We can reset the slow log using the SLOWLOG RESET command. Once we delete the information it is lost forever.

[Need help with the Slow Log? We are available 24*7]

 

Conclusion

In short, Redis Slow Log is one of the best tools to debug and trace the Redis database. Today, we saw how our Support Techs use it to perform the task.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF