Server

A Redis Server hosts a configurable of databases, indexed from 0. Each database is a flat key-value store which can contain values of a number of types:

  • Strings, up to 512MB in length.
  • Hashes of string-string pairs.
  • Lists of strings.
  • Sets of strings, similar to lists but which disallow duplicates.
    • Sorted sets

Redis Server

In a basic Redis deployment a number of clients interact with a single Redis server over the Redis protocol.

There's no provision for high availability, though Redis Server does allow for one-way replication betweeen a Redis master and replica. Any failover must be managed by an external tool.

Checking availability

You can ping anything that supports the Redis protocol, either a Redis Server or Redis Sentinel:

$ redis-cli PING
PONG

Checking status

To retrieve all status information:

$ redis-cli info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:9435c3c2879311f3
redis_mode:standalone
os:Linux 4.18.0-1018-azure x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:7.4.0
process_id:103413
run_id:5349d5d25901b295e47deceaf12dad531db7bb4d
tcp_port:6379
uptime_in_seconds:9875766
uptime_in_days:114
hz:10
lru_clock:12938017
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf

# Clients
connected_clients:185
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:49927032
used_memory_human:47.61M
used_memory_rss:65818624
used_memory_rss_human:62.77M
used_memory_peak:68322488
used_memory_peak_human:65.16M
used_memory_peak_perc:73.08%
used_memory_overhead:7102080
used_memory_startup:782480
used_memory_dataset:42824952
used_memory_dataset_perc:87.14%
total_system_memory:1996668928
total_system_memory_human:1.86G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.32
mem_allocator:jemalloc-3.6.0
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:2736
rdb_bgsave_in_progress:0
rdb_last_save_time:1573218822
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:8556544
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

# Stats
total_connections_received:2844
total_commands_processed:1078972612
instantaneous_ops_per_sec:4
total_net_input_bytes:139364909714
total_net_output_bytes:16462621631410
instantaneous_input_kbps:0.16
instantaneous_output_kbps:4.37
rejected_connections:0
sync_full:2
sync_partial_ok:1
sync_partial_err:2
expired_keys:21967913
expired_stale_perc:0.22
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:917066119
keyspace_misses:28560778
pubsub_channels:1
pubsub_patterns:0
latest_fork_usec:1408
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

# Replication
role:master
connected_slaves:1
slave0:ip=10.146.16.53,port=6379,state=online,offset=32252795531,lag=1
master_replid:8f303d0856e47d123e21625a239008b107aed1c0
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:32252795615
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:32251747040
repl_backlog_histlen:1048576

# CPU
used_cpu_sys:44728.56
used_cpu_user:24944.73
used_cpu_sys_children:1261.92
used_cpu_user_children:8313.35

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=3,expires=0,avg_ttl=0
db1:keys=40,expires=0,avg_ttl=0
db2:keys=5825,expires=5809,avg_ttl=7245029
db4:keys=16,expires=0,avg_ttl=0
db5:keys=2948,expires=2924,avg_ttl=3718039
db6:keys=2,expires=0,avg_ttl=0
db7:keys=13,expires=0,avg_ttl=0
db8:keys=5872,expires=5850,avg_ttl=3591247
db10:keys=11,expires=0,avg_ttl=0
db11:keys=5871,expires=5853,avg_ttl=3657482
db13:keys=11,expires=0,avg_ttl=0

You can provide an optional section name to fetch only the information you need:

$ redis-cli info keyspace
# Keyspace
db0:keys=3,expires=0,avg_ttl=0
db1:keys=40,expires=0,avg_ttl=0
db2:keys=5826,expires=5810,avg_ttl=7326502
db4:keys=16,expires=0,avg_ttl=0
db5:keys=2943,expires=2919,avg_ttl=3586301
db6:keys=2,expires=0,avg_ttl=0
db7:keys=13,expires=0,avg_ttl=0
db8:keys=5873,expires=5851,avg_ttl=3732504
db10:keys=11,expires=0,avg_ttl=0
db11:keys=5868,expires=5850,avg_ttl=3620568
db13:keys=11,expires=0,avg_ttl=0