Zettelkasten

Redis Replication

·수정 2026.04.23·수정 3

https://www.youtube.com/watch?v=esbRryo0Ty8&ab_channel=Redis

Replication Basic

  • master가 있고 Replica가 있음
  • 비동기로 동기화됨
  • Redis Failover service(ex, sentinel) 같은게 있어서 promote 하거나 함
  • 복제는 비동기
    • replication은 master에 non blocking
    • 다른 replica에서는 replication은 block operations 함
    • master는 개수에 상관없이 replica를 가질 수 있음
    • 일반적으로 replica는 read only
    • Replica는 마스터 될 수 있음

Need for replication

  • high availability
  • spread the read load across replicas
  • replication in lieu of Persistence

replication 종류

  • full sync
    • entire data is transferred to replica
    • dump not saved on master in diskless mode
    • used when
      • bootstrappin a new replica
      • existing replica too far behind to do partial sync
  • partial sync
    • Replication backlog circular buffer
      • 최근 전송 명령들을 저장해두는 순환 버퍼
    • replication id
    • replication offset
    • replica client output buffer
      • 슬레이브 마다 따로 있는 출력 버퍼, 슬레이에 보낼 명령을 임시로 보관
      • 슬레이브가 느리면 이 버퍼에 쌓임
      • 너무 커지면 슬레이브 강제 종료

Redis architecture.png

Redis memory usage of replication 2.png

replication backlog

  • replica_backlog_first_byte_offset
    • Redis는 replication backlog라는 순환 버퍼에 최근 전송한 명령을 저장해놓는데, 그 버퍼에 저장된 가장 오래된 바이트의 오프셋
  • master_repl_offset: > 마스터 노드가 보낸 전체 바이트 수

data consistency on replication

  • set balance 10,000 to master
  • get balance to slave
  • replication은 비동기로 진행됨, 팬텀 read?
  • best effort consistency
    • read only from master
    • server config: min-replicas-to-write, min-replicas-max-lag
    • client call: wait num-replicas time-out-milis

memory usage on replica

Redis memory usage of replication 2.png

database replication

이 문서를 참조하는 노트 (1)