Bobcares

How to troubleshoot Redis errors?

by | Sep 11, 2020

Redis, an in-memory key-value data store comes with several commands that help us to debug and troubleshoot redis errors.

As a part of our Server Management Services, we help our Customers to fix Redis related errors regularly.

Let us today discuss the steps to troubleshoot Redis errors.

How to troubleshoot Redis Memory-related errors?

As we discussed earlier, Redis comes up with several commands that help us to troubleshoot and debug its issues.

Many of these focus on memory management as Redis is an in-memory key-value store. Further, there are commands available to provide an overview on the status of the Redis server as well.

First command is the one that measures the current memory usage. “memory usage” tells us the amount of memory that a single key currently uses. It takes the name of a key as an argument and outputs the number of bytes it uses:

127.0.0.1:6379> memory usage key_testkey
Output
(integer) 42

Another one The memory malloc-stats provides an internal statistics report from jemalloc, the memory allocator used by Redis on Linux systems:

127.0.0.1:6379> memory malloc-stats

For a more general understanding of how your Redis server is using memory, we can run the memory stats command:

127.0.0.1:6379> memory stats

It outputs an array of memory-related metrics and their values. Let us now look at those metrics.

Metrics reported by memory stats

Some of the metrics reported by memory stats include:

  • peak.allocated: The peak number of bytes consumed by Redis
  • total.allocated: The total number of bytes allocated by Redis
  • startup.allocated: The initial number of bytes consumed by Redis at startup
  • replication.backlog: The size of the replication backlog, in bytes
  • clients.slaves: The total size of all replica overheads (the output and query buffers and connection contexts)
  • clients.normal: The total size of all client overheads
  • aof.buffer: The total size of the current and rewrite append-only file buffers
  • db.0: The overheads of the main and expiry dictionaries for each database in use on the server, reported in bytes
  • overhead.total: The sum of all overheads used to manage Redis’s keyspace
  • keys.count: The total number of keys stored in all the databases on the server
  • keys.bytes-per-key: The ratio of the server’s net memory usage and keys.count
  • dataset.bytes: The size of the dataset, in bytes
  • dataset.percentage: The percentage of Redis’s net memory usage taken by dataset.bytes
  • peak.percentage: The percentage of peak.allocated taken out of total.allocated
  • fragmentation: The ratio of the amount of memory currently in use divided by the physical memory Redis is actually using

Another tool available to detect memory consumption issue is the memory doctor. This feature will output any memory consumption issues that it can find and suggest potential solutions.

127.0.0.1:6379> memory doctor

 

Getting General Information about the Redis Instance

A debugging command that is not directly related to memory management is monitor. This command allows you to see a constant stream of every command processed by the Redis server:

127.0.0.1:6379> monitor

Output
OK
1566157213.896437 [0 127.0.0.1:47740] "auth" "foobared"
1566157215.870306 [0 127.0.0.1:47740] "set" "key_1" "878"

Another command useful for debugging is info, which returns several blocks of information and statistics about the server:

127.0.0.1:6379> info

Output
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:9435c3c2879311f3
redis_mode:standalone
os:Linux 4.15.0-52-generic x86_64

This command by default returns a lot of information. To return only info block, we can specify it as an argument to info:

127.0.0.1:6379> info CPU

Output
# CPU
used_cpu_sys:173.16
used_cpu_user:70.89
used_cpu_sys_children:0.01
used_cpu_user_children:0.04

 

Using the keys Command

The keys command is helpful in cases where we have forgotten the name of a key, or perhaps we have created one but accidentally misspelled its name. It looks for keys that match a pattern:

127.0.0.1:6379> keys pattern

[Need any further assistance to troubleshoot Redis error? – We’re available 24*7]

Conclusion

In short, Redis comes up with several commands that help us to troubleshoot and debug its issues. Today, we saw how our Support Engineers troubleshoot Redis error.




			

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 *

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