- Today
- Total
개성있는 개발자 되기
Redis-Exporter에서 표시되는 Graph 수치 본문
Redis-Exporter에서 추출되는 Metrics 는 Redis의 INFO에 기반되어 있다.
redis> INFO
# Server
redis_version:999.999.999
redis_git_sha1:5babacad
redis_git_dirty:0
redis_build_id:a31260535f820267
redis_mode:standalone
os:Linux 4.8.0-1-amd64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:6.3.0
process_id:6777
run_id:8d252f66c3ef89bd60a060cf8dc5cfe3d511c5e4
tcp_port:6379
uptime_in_seconds:571487
uptime_in_days:6
hz:10
configured_hz:10
lru_clock:7543341
executable:/usr/local/bin/redis-server
config_file:
# Clients
connected_clients:4
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
# Memory
used_memory:82044184
used_memory_human:78.24M
used_memory_rss:87617536
used_memory_rss_human:83.56M
used_memory_peak:89401456
used_memory_peak_human:85.26M
used_memory_peak_perc:91.77%
used_memory_overhead:23007656
used_memory_startup:524192
used_memory_dataset:59036528
used_memory_dataset_perc:72.42%
allocator_allocated:82026272
allocator_active:82272256
allocator_resident:85856256
total_system_memory:4147884032
total_system_memory_human:3.86G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:1073741824
maxmemory_human:1.00G
maxmemory_policy:allkeys-lru
allocator_frag_ratio:1.00
allocator_frag_bytes:245984
allocator_rss_ratio:1.04
allocator_rss_bytes:3584000
rss_overhead_ratio:1.02
rss_overhead_bytes:1761280
mem_fragmentation_ratio:1.07
mem_fragmentation_bytes:5656880
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:133456
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
# Persistence
loading:0
rdb_changes_since_last_save:2092655
rdb_bgsave_in_progress:0
rdb_last_save_time:1584030158
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
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
module_fork_in_progress:0
module_fork_last_cow_size:0
# Stats
total_connections_received:36431
total_commands_processed:4974845
instantaneous_ops_per_sec:39
total_net_input_bytes:410196323
total_net_output_bytes:75072158
instantaneous_input_kbps:3.13
instantaneous_output_kbps:0.35
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:12727
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:18730
evicted_keys:0
keyspace_hits:1118624
keyspace_misses:496662
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
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
tracking_total_keys:0
tracking_total_items:0
# Replication
role:master
connected_slaves:0
master_replid:0d904704e424e38c3cd896783e9f9d28d4836e5e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:1017.828000
used_cpu_user:2140.512000
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
# Modules
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=453887,expires=4,avg_ttl=395708190039945
https://redis.io/commands/info
1. Hits / Misses perSec
Hit률과 Miss률을 동시에 보여주는 다이어그램
irate(redis_keyspace_hits_total{instance=~"$instance"}[10m]) // Hit률
irate(redis_keyspace_misses_total{instance=~"$instance"}[10m]) // Miss률
Redis Hits, Misses
Info Stats명령을 실행했을 때 나오는 keyspace_hits, keyspace_misses에 대한 설명이다.
Hits와 misses는 조회(get) 명령을 실행했을 때
- 해당 키가 있으면 hits가 증가
- 해당 키가 없으면 misses가 증가
- 쓰기(set), 삭제(del) 명령은 해당되지 않음
- 조회 명령만 카운트하므로 hits + misses가 total_commands_processed와 일치하지 않습니다.
- 클론(슬레이브) 노드도 동일하게 적용됩니다.
- config resetstat 명령으로 초기화됩니다.
- Misses는 expire된 키를 조회하거나 원래부터 없던 키를 조회한 것입니다. Misses가 예상보다 높다면 확인해 보시기 바랍니다.
데이터 타입 별 Hit, Miss가 적용되는 대표적인 명령
- Strings: get, mget, getrange, getset
- Lists: lrange, llen, lindex
- Sets: sismember, scard, spop, srandmember, strlen, sscan
- SortedSets: zrange, zcard, zcount, zrank, zscore, zscan
- Hashes: hget, hgetall, hlen, hexists, hstrlen, hscan
2. Network I/O
레디스 서버에서 Read 비율과, 레디스 서버에 Write 비율을 나타내는 다이어그램
rate(redis_net_input_bytes_total{instance=~"$instance"}[10m]) // Read
rate(redis_net_output_bytes_total{instance=~"$instance"}[10m]) // Write
- total_net_input_bytes: The total number of bytes read from the network
- total_net_output_bytes: The total number of bytes written to the network
3. Commands Executed / sec
서버에 수행된 총 Command 수를 1초당 환산된 비율
rate(redis_commands_processed_total{instance=~"$instance"}[10m])
- total_commands_processed: Total number of commands processed by the server
4. Memory Usage
(사용자가 설정한) Max 메모리 기준 사용된 메모리 비율
100 * (redis_memory_used_bytes{instance=~"$instance"} / redis_memory_max_bytes{instance=~"$instance"} )
- used_memory: Total number of bytes allocated by Redis using its allocator (either standard libc, jemalloc, or an alternative allocator such as tcmalloc)
- maxmemory: The value of the maxmemory configuration directive
5. Total Items per DB
레디스 DB에 있는 Key 수
sum (redis_db_keys{instance=~"$instance"}) by (db)
6. Expired / Evicted
레디스 Expired Key / Evicted Key
sum(rate(redis_expired_keys_total{instance=~"$instance"}[10m])) by (instance)
sum(rate(redis_evicted_keys_total{instance=~"$instance"}[10m])) by (instance)
Evicted 란
Redis 는 ‘evicted_keys’ 가 존재하는데 보통은 메모리 부족현상으로 발생
evicted_key 가 증가하는 현상이 보인다면 maxmemory 값을 늘려주는게 좋다.
memory가 limit에 도달했을 때 Redis는 선택된 eviction policy(제거 정책)(maxmemory-policy)에 따라서 key들을 제거할 것이다.
만약 Redis가 eviction policy에 의해서 key를 제거하지 못하거나 polict가 'noeviction'으로 설정되어 있다면, SET, LPUSH와 같이 메모리를 사용하는 command들에 대ㅐ서는 error를 반환하고, 오직 GET 같은 read-only command들에 대해서만 응답할 것이다.
출처: https://moss.tistory.com/entry/Redis-서버-설정-정리 [What is good?]
7. Command Calls / sec
레디스 서버에 수행된 Call 중, 각 명령어 기준으로 초당 수행된 Call로 나타냄 (Auth, hget, hset, get 등등)
예시:
redis_commands_total{cmd="auth"} 20231
redis_commands_total{cmd="client"} 12112
redis_commands_total{cmd="command"} 15
redis_commands_total{cmd="config"} 12121
redis_commands_total{cmd="dbsize"} 82
redis_commands_total{cmd="del"} 274
redis_commands_total{cmd="exists"} 1182
redis_commands_total{cmd="expire"} 2
redis_commands_total{cmd="flushall"} 6
redis_commands_total{cmd="flushdb"} 6
redis_commands_total{cmd="get"} 8.50847e+06
redis_commands_total{cmd="hget"} 19978
redis_commands_total{cmd="hgetall"} 757
redis_commands_total{cmd="hkeys"} 1298
redis_commands_total{cmd="hlen"} 3247
redis_commands_total{cmd="hmget"} 401
redis_commands_total{cmd="hmset"} 105
redis_commands_total{cmd="hscan"} 738
redis_commands_total{cmd="hset"} 1.2911999e+07
redis_commands_total{cmd="hvals"} 7
redis_commands_total{cmd="incr"} 400000
redis_commands_total{cmd="info"} 234078
redis_commands_total{cmd="keys"} 5
redis_commands_total{cmd="latency"} 12111
redis_commands_total{cmd="llen"} 2
redis_commands_total{cmd="lpop"} 800000
redis_commands_total{cmd="lpush"} 1.2e+06
redis_commands_total{cmd="lrange"} 1.447575e+06
redis_commands_total{cmd="mset"} 300000
redis_commands_total{cmd="object"} 68
redis_commands_total{cmd="ping"} 800263
redis_commands_total{cmd="psubscribe"} 8
redis_commands_total{cmd="pubsub"} 81
redis_commands_total{cmd="renamenx"} 1
redis_commands_total{cmd="rpop"} 400000
redis_commands_total{cmd="rpush"} 400000
redis_commands_total{cmd="sadd"} 800105
redis_commands_total{cmd="scan"} 7048
redis_commands_total{cmd="scard"} 36
redis_commands_total{cmd="select"} 1183
redis_commands_total{cmd="set"} 1.7485716e+07
redis_commands_total{cmd="setex"} 70829
redis_commands_total{cmd="sismember"} 1
redis_commands_total{cmd="slowlog"} 24222
redis_commands_total{cmd="smembers"} 51
redis_commands_total{cmd="spop"} 800000
redis_commands_total{cmd="sscan"} 5
redis_commands_total{cmd="strlen"} 326
redis_commands_total{cmd="ttl"} 1362
redis_commands_total{cmd="type"} 6198
8. 레디스 기본정리
- Max Memory 관련
https://brunch.co.kr/@jehovah/20
https://americanopeople.tistory.com/179
'Open Source > Redis' 카테고리의 다른 글
Redis Exporter 프로메테우스 Metrics (0) | 2020.03.19 |
---|---|
Redis-cli 사용법 (1) | 2020.03.19 |
RedisTemplate 을 이용해서 Multi Pojo get/set 할 때 이슈사항 (1) | 2020.03.11 |