Nâng CaoRedis iconRedis

Redis Cluster hoạt động như thế nào? Sharding, slot allocation, và resharding?

Redis Cluster chia keyspace thành 16384 hash slot; mỗi key được hash bằng CRC16 và map vào một slot cụ thể (slot = CRC16(key) % 16384).

  • Mỗi master node chịu trách nhiệm một range slot (ví dụ: node A: 0-5460, node B: 5461-10922, node C: 10923-16383), mỗi master có ít nhất một replica.
  • Client dùng CLUSTER-aware client library để route request trực tiếp đến node chứa slot tương ứng; nếu route sai, node trả về MOVED redirect.
  • Hash tags ({user}.profile) cho phép force nhiều key vào cùng một slot để support multi-key operations và transaction.
  • Resharding (di chuyển slot giữa các node) được thực hiện online không cần downtime bằng redis-cli --cluster reshard.
  • Minimum recommended: 3 master + 3 replica (total 6 nodes) để có HA và survive node failure.
  • Limitation: không support cross-slot transaction và multi-key operation (trừ khi dùng hash tag).

Xem toàn bộ Redis cùng filter theo level & chủ đề con.

Mở danh sách Redis