Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of redis slow log slowlog

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail what is the use of redis slow log slowlog for you. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Redis slow log slowlog

What is 1 slowlog?

Redis's slowlog is a logging system used by redis to record the execution time of slow queries. Because slowlog is kept only in memory, slowlog is very efficient and doesn't have to worry about affecting the performance of redis. Slowlog is a command introduced by Redis from version 2.2.12.

2 slowlog Settin

Slowlog can be set in two ways:

2.1 redis.conf Settings

There are settings for slowlog in redis.conf:

2 slowlog-log-slower-than 10000

Slowlog-max-len 128

Slowlog-log-slower-than indicates the demarcation of slowlog. Only those whose query execution time is longer than slowlog-log-slower-than will be defined as slow queries and will be recorded by slowlog. The unit set by slowlog-log-slower-than is subtle, and the default is 10000 subtleties, that is, 10ms

Slowlog-max-len indicates the maximum number of slow queries. When the slowlog exceeds the set maximum, the earliest slowlog will be deleted. It is a FIFO queue.

2.2 use config to set slowlog dynamically

As follows, you can set slowlog dynamically through config

10-View current slowlog-log-slower-than settin

127.0.0.1 purl 6379 > CONFIG GET slowlog-log-slower-than

1) "slowlog-log-slower-than"

2) "10000"

-set slowlog-log-slower-than to 100ms

127.0.0.1 6379 > CONFIG SET slowlog-log-slower-than 100000

OK

-set slowlog-max-len to 1000

127.0.0.1 6379 > CONFIG SET slowlog-max-len 1000

OK

3 slowlog View

3.1 View the total number of slowlog entries

2 127.0.0.1 purl 6379 > SLOWLOG LEN

(integer) 4

3.2 View slowlog

29 127.0.0.1 purl 6379 > SLOWLOG GET

1) 1) (integer) 25

2) (integer) 1440057769

3) (integer) 6

4) 1) "SLOWLOG"

2) "LEN"

2) 1) (integer) 24

2) (integer) 1440057756

3) (integer) 36

4) 1) "CONFIG"

2) "GET"

3) "slowlog-log-slower-than"

3) 1) (integer) 23

2) (integer) 1440057752

3) (integer) 11

4) 1) "CONFIG"

2) "SET"

3) "slowlog-log-slower-than"

4) "1"

4) 1) (integer) 22

2) (integer) 1440057493

3) (integer) 27

4) 1) "CONFIG"

2) "GET"

3) "slowlog-log-slower-than"

5) 1) (integer) 21

2) (integer) 1440057133

3) (integer) 7

4) 1) "monitor"

If you want to get the specified number of entries, you can use the SLOWLOG GET N command?

6 127.0.1 SLOWLOG GET 6379 >

1) 1) (integer) 26 / / slowlog unique serial number id

2) (integer) 1440057815 / / timestamp of the query

3) (integer) 47 / / query time (subtle), for example, this command query takes 47 microseconds

4) 1) "SLOWLOG" / / query command. The full command saves up to 31 key and 128characters for SLOWLOG GET,slowlog.

2) "GET"

This is the end of this article on "what is the use of redis slow log slowlog". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report