Redis Info

Difficulty: Beginner

Question

What does the INFO command do in Redis, and which fields do you check when something is wrong?

Answer

INFO returns a text report of the Redis server's state and statistics, grouped into sections like server, clients, memory, persistence, stats, replication, cpu and keyspace. It is the first command to run when diagnosing slowness, memory pressure, or replication trouble, and it is what monitoring tools such as the Prometheus redis_exporter scrape under the hood.

Calling it

  • INFO returns the default sections.
  • INFO memory returns one section. Since Redis 7.0 you can pass several: INFO memory stats.
  • INFO all adds commandstats, latencystats and errorstats. INFO everything also includes module sections.
  • Output is field:value lines, easy to grep or parse.

The fields that matter most

SectionFieldWhat it tells you
serverredis_version, uptime_in_secondsVersion and whether it restarted recently
clientsconnected_clients, blocked_clientsConnection leaks, many clients stuck on BLPOP
memoryused_memory_human, maxmemory_humanHow close you are to the limit
memorymem_fragmentation_ratioFragmentation (high) or swapping (below 1)
statsinstantaneous_ops_per_secCurrent throughput
statskeyspace_hits, keyspace_missesCache hit ratio
statsevicted_keys, expired_keysMemory pressure and TTL activity
statsrejected_connectionsmaxclients reached
persistencerdb_last_bgsave_status, aof_last_write_statusWhether saves are failing
replicationrole, master_link_status, connected_slavesReplica health and lag
keyspacedb0:keys=...,expires=...Key counts per database

Using INFO to debug real problems

  1. Cache feels slow and the DB is overloaded: compute hit ratio as keyspace_hits / (keyspace_hits + keyspace_misses). A low ratio means bad keys, short TTLs, or eviction. Check whether evicted_keys is climbing.
  2. OOM errors on writes: compare used_memory with maxmemory and look at maxmemory_policy. With noeviction, writes fail once full.
  3. Memory higher than expected at the OS level: look at used_memory_rss against used_memory and the fragmentation ratio.
  4. Replica serving stale data: on the replica, master_link_status:down or a growing master_last_io_seconds_ago means it is disconnected.
  5. Latency spikes: INFO commandstats shows calls and microseconds per call per command, so a heavy KEYS or HGETALL stands out. Pair it with SLOWLOG GET.

Practical tips

  • Counters in stats are cumulative since start or the last CONFIG RESETSTAT. Graph their rate of change, not the raw value.
  • INFO is cheap and safe to run in production, unlike KEYS or MONITOR.
  • On managed services such as ElastiCache, the same numbers appear as CloudWatch metrics, but INFO is still the ground truth.
  • Some fields still use legacy naming like role:slave and connected_slaves for compatibility.
Main INFO sections. Each section answers a different operational question.
  1. server: Version, uptime, config file, process ID.
  2. clients: Connected, blocked and tracking clients.
  3. memory: Used, RSS, peak, fragmentation, maxmemory.
  4. persistence: RDB and AOF status and timings.
  5. stats: Ops per second, hits, misses, evictions.
  6. replication: Role, replicas, offsets, link status.
  7. keyspace: Keys and expiring keys per database.

Code examples

Quick health check from the shell

# Memory and eviction
redis-cli INFO memory | grep -E 'used_memory_human|maxmemory_human|mem_fragmentation_ratio'

# Throughput and cache effectiveness
redis-cli INFO stats | grep -E 'instantaneous_ops_per_sec|keyspace_(hits|misses)|evicted_keys'

# Replication health
redis-cli INFO replication | grep -E 'role|master_link_status|connected_slaves'

# Which commands cost the most time
redis-cli INFO commandstats | sort -t= -k3 -nr | head

Here the hit ratio is about 96%, memory is at about 81% of maxmemory, and there are no evictions yet.

Computing hit ratio in Node.js

import Redis from 'ioredis';
const redis = new Redis();

const text = await redis.info('stats');
const stats = Object.fromEntries(
  text.split('\r\n')
    .filter((l) => l && !l.startsWith('#'))
    .map((l) => l.split(':'))
);

const hits = Number(stats.keyspace_hits);
const misses = Number(stats.keyspace_misses);
console.log('hit ratio', (hits / (hits + misses)).toFixed(3));

INFO output is CRLF-separated field:value lines with # section headers, so it is easy to parse.

Key points

  • INFO returns server state grouped into sections; pass a section name to narrow it.
  • Hit ratio = keyspace_hits / (hits + misses).
  • Watch used_memory vs maxmemory, evicted_keys and mem_fragmentation_ratio.
  • INFO commandstats shows per-command call counts and time.
  • Stats counters are cumulative; reset with CONFIG RESETSTAT.

Common follow-up questions

  • How would you tell whether high memory usage is from data or fragmentation?
  • What would a rising evicted_keys counter tell you?
  • How would you monitor Redis in production with Prometheus and Grafana?
  • What other commands help debug latency besides INFO?

Interview tips

  • Name specific fields and what each diagnoses; generic answers sound like no hands-on experience.
  • Show you can compute the hit ratio from INFO stats.
  • Tie it to a real debugging story, such as tracing DB load back to a low hit ratio.

Concepts covered

INFO Sections, Memory Metrics, Keyspace Hit Ratio, Replication Status, Monitoring

More Redis & Caching questions