tags: Database redis Distributed
1. Introduction:
Redis's slow query log is responsible for logging over the query operation that exceeds the specified execution time.This execution time does not include I / O operations (for example, communication between the server and the client, send a response message, etc.)It is only the time to execute the command actually need to consume (only at the stage of command execution, Redis will block the thread, and other requests cannot be handled).
2. Command execution process
1) Client send command
2) The REDIS server receives the command, queue the command
3) The command in the queue is executed.Slow query only the time to step 3)So there is no slow query does not mean that the client has no timeout problem.
4) Return the result
1. Slow query log has two configuration parameters:
1)slowlog-log-slower-thanThe parameter is used to specify the upper limit value of the execution time (in microseconds), and the redis records the execution time exceeds the query operation of this upper limit. Note: If this parameter is set to a negative number, the slow query log is disabled; if this parameter is set to zero, each command will be enforced.
2)slowlog-max-lenThe parameter is used to specify the maximum length of the slow query log. The minimum value of this parameter is zero. When Redis records a new command into a slow query log, if the slow query log has reached the maximum length, the redis will remove the oldest command log from the log queue, so that the new command log is spatially.
2. You can configure the above two parameters in the redis.conf file, or you can configure the Config Get and Config Set commands when REDIS runtime, and then use config reference to the local configuration file.
Example:
config set slowlog-log-slower-than 20000 # This unit is microseconds, that is, 20ms
config set slowlog-max-len 1000
config rewrite
slowlog get [n]


You can use the Slowlog Reset command to reset the slow query log. Once deleted, the previously recorded slow query log will be permanently lost.
The output format of the slow query log is shown below:
The unique identifier of the log entry can be used to avoid multiple repetitions of the same slow query log entries (for example, you may use a script, whenever a new slow query log entry is generated, you will send you a alarm message) . (This identifier will never be reset during the run of the REDIS server, and will only be reset when the server is restarted.)


Supplement:
1.Redis slow query because the command queuing mechanism will cause other command levels, so when the client requests timeout, you need to check if the time point has a corresponding slow query.
By executing the Monitor command, the client can turn itself into a monitor (server maintenance oneMonitor chain tableEach time you receive the client command, send command information to the monitor, receive and print the information requested by the server currently processed in real time:

1. What is slow log Slow log is a log system used by Redis to record query execution time. The query execution time refers to the time it takes to execute a query command without including IO operatio...
Redis runs in a single thread. A slow execution will delay a large number of subsequent executions and greatly reduce the throughput. It is of great significance to record, query, and monitor the slow...
Slow query settings inredis.confYou can configure and slow query logs related options: RedisUse the list to store slower query logs, use the queue mode (FIFO) Slow query record redisServerSave ...
Configuration option slowlog-log-slower-than slowlog-max-len Related command Slow query record slowlog_entry_id slowlog Reading and removing of slow query logs reading delete Add a new log Focus In th...
Lua script Lua is a lightweight scripting language, written in standard C language and is open in source code, and its design is to embed the application, providing flexible extension and customizatio...
How much does the setting execute began to record? Set up a slow query log record View slow query log...
Redis slow query log (FIFO queue) used to record command requests that are executed more than a given time, The server configuration has two options related to slow query logs: Slowlog-log-slower-tan ...
Foreword As mentioned earlier, each component of elk has been installed and used by x-pack. The specific joint operation is not described in detail. This article uses logstach to collect mysql slow lo...
Foreword As mentioned earlier, each component of elk has been installed and used by x-pack. The specific joint operation is not described in detail. This article uses logstach to collect mysql slow lo...
Steps First use the user to log in to the linux client, execute the command mysql -u root -p, root is the database user name, the system will prompt for the password, enter the password and press Ente...