Redis Config Explain

Redis Config Section

redis-cli를 통해서 redis console에 진입 할 경우 info명령어를 통해서 다음 section에 대한 정보를 획득 할 수있다.

info <<아래 명령어>>

  • server : 기본 정보
  • clients : client의 접속 정보
  • memory : 메모리 사용 관련 정보
  • persistence : RDB와 AOF(Append Only File) 관련 정보

AOF의 경우는 appendonly.aof 파일에 입력/수정/삭제 실행 명령 실행시 마다 기록 (조회 제외)

Redis 서버 작동시 FLUSHALL명령을 사용한 경우 해당 파일을 이용해서 DB를 재 구축 할 수 있음

http://redisgate.kr/redis/configuration/persistence.php

RDB의 경우에는 현재 메모리에 있는 redis data를 특정 시점을 기준으로 파일로 write 한 일종의 backup 파일 또는 스냅샷으로 생각 하면 된다.

  • stats : 일반 통계 정보
  • replication : Master, Slave간에 데이터 복사에 대한 설정
  • cpu : cpu 사용 통계
  • commandstats : redis에 command를 처리한 통계
  • cluster : redis cluster에 대한 설정 (master, slave 등)
  • keyspace : database 관련 통계

server

redis_version : redis 서버 버전
redis_git_sha1 : git sha1 (?)
redis_git_dirty : git dirty flag (?)
redis_build_id

소스로 부터 redis를 빌드한 id

redis_mode

standalone : 독립적으로 동작

sentinel : sentinel에 의해 모니터링 되고 관리됨

cluster : redis간 clustering 처리

os
arch_bits

32bits or 64bits

multiplexing_api (?)

evnet loop 메카니즘

process_id

서버 PID

tcp_port

TCP/IP 리슨포트 (6379 기본 포트)

uptime_in_seconds

redis server 작동 후 시간

uptime_in_days

redis server 작동 후 일자

lru_clock

LRU 알고리즘을 위한 시간 (매분 마다 증가함)

Least Recently Used 가장 오랫동안 접근 되지 않은 키의 데이터를 삭제한다는 의미

excutable

실행 파일 위치

config_file

환경 설정 파일 위치

clients

connected_clients

현재 접속 되어 있는 clients 개수 (replicas를 통한 접근 제외)

client_longest_output_list

현재 접속되어 있는 clients 중에 가장 오래 output(? 가장 오래 접속 하고 있는 의미로 보임)하고 있는 list

client_biggest_input_buf

현재 접속되어있는 clients 중에 가장 큰 input buffer를 넣고 있는 connection

blocked_clients

blocking call(BLPOP, BRPOP, BRPOPLPUSH)에 의해 blocked 되어있는 client 개수

BLPOP(리스트의 처음), BRPOP(리스트의 마지막),BRPOPLPUSH (원본 마지막으로 대상 리스트의 첫번째로 입력) 명령어의 경우 기본적으로 blocking 모드 작동을 한다. 즉, 해당 command가 작동 중에는 다음 command는 blocking 되게 된다.

memory

used_memory

redis가 사용중인 총 메모리양

used_memory_human

사람이 읽을 수있는 메모리양 표시 (G로 표시한다)

used_memory_rss

OS상에서 사용중인 메모리양

일반적으로 해당 솔루션에서 사용된 메모리양 + shared 메모리양의 총합으로

used memory 보다 크다

used_memory_rss_human

사람이 읽을 수 있는 메모리양 표시 (G로 표시한다)

used_memory_peak

바이트 단위로 메모리가 peak에 있을 때 사용량

used_memory_peak_perc

used_memory 대비 used_memory의 퍼센트 (peak이 더 높다)

used_memory_overhead

모든 overheads에 대한 바이트 합

used_memory_startup

redis가 start하는 시점에 사용된 전체 메모리양

used_memory_dataset

dataset의 바이트 단위 사이즈

maxmemory

설정된 최대 메모리

32bit의 경우는 3G

64bit의 경우는 0 (unlimit로 처리 되는 것으로 보임)

maxmemory_policy
  • noeviction : memory의 limit에 접근하면 에러를 낸다
  • allkeys-lru : 신규 데이터 입력시 key를 기반으로 LRU 알고리즘 적용
  • volatile-lru : allkeys-lru와 같은 조건이나, expire set이 있는 경우만 대상으로 함

EXPIRE (https://redis.io/commands/expire) 명령어로 지정된 key를 대상으로만 하는 것으로 보임

  • allkeys-random : random으로 삭제(진짜?)
  • volatile-random : expire set이 있는 경우만 random으로 삭제
  • volatile-ttl : expire set의 ttl을 확인 후 최우선으로 삭제

https://redis.io/topics/lru-cache

persistence

loading

dump 파일이 로딩 중인지 표시 한다 (평소에는 0이다가 로딩하게 되면 1로 변화하는 것으로 보인다)

rdb_changes_since_last_save

마지막 dump 후 변경된 횟수

rdb_last_save_time

epoch 기준으로 마지막 성공한 저장 시점

aof_enabled

aof 설정 여부 (0 false)

replication

role

master or slave

master_replid

redis server replication ID

master_repl_offset

현재 서버의 replication offset

Redis Sentinel 사용시 수시 Disconnect가 발생하는 경우

sentinel down-after-milliseconds mymaster 3000

설정을 확인한다.

상위에서 마지막 부분에 있는 3000은 3초를 의미 한다. 이를 매우 작게 사용한다면 Redis간 Sync시 Disconnect를 감지하고 Master Slave 전환을 처리 하게 된다. 일반적으로 3초에서 5초 사이로 설정해 놓고 쓰면된다.

Reids Sync 처리 프로세스를 실행하기 전에 Master에서 BGSAVE처리를 하게 된다. BGSAVE는 메모리 데이터를 파일로 Write하는 행동인데, 이때 Redis 소스 내부적으로 Slave와 Disconnect를 처리 한다. 이 순간의 단절 상황을 Sentinel에서 감지하게 되는 문제이다.

client-output-buffer-limit

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

Redis와 Slave 간의 데이터 이동 양을 정하는 부분이다

client-output-buffer-limit slave 256mb 64mb 60

  • hard : 최대 256mb의 데이터를 송수신 할 수 있다. 넘어가면 Disconnect가 발생한다.
  • Soft : 64mb 데이터를 60초 동안 이동 시킨다. 넘어가면 Disconnect가 발생한다.