Giter Site home page Giter Site logo

Comments (3)

huangzworks avatar huangzworks commented on July 17, 2024

你好,关于你的两个问题,解答如下。

其一:

客户端向 slave 发送什么命令,要由程序来决定,如果程序向一个 slave 发送了写命令,那么这个写命令将被拒绝,因此程序有责任将正确的命令发送给正确的服务器 —— 将写命令发送给 master ,将读命令发送给 slave ,而这些目前需要使用程序手动去做。

有一些数据库也支持只读 slave ,但是它们的 slave 可以在接到写命令时,自动把客户端引导至 master ,并让客户端重新发送命令(这好像被称为“读写分离”特性?),而不会像 Redis 的 slave 那样,直接返回错误,不过我用过的 Ruby 和 Python 客户端都不支持这种特性,至于其他客户端是否支持,我不太清楚。

其二:

官网说的是对的, Redis 目前的主从复制没办法保持强制一致性:当你向 master 发送一条写命令之后, master 会向 slave 发送相同的写命令,而这条写命令在发送的过程中可能会有一段时间延迟,这段延迟时间之内, master 和 slave 的数据并不是完全一致的。

为了规避这一缺陷,如果你需要执行一个写然后读(write-and-read)操作,那么为了确保数据的正确性,你应该直接写和读 master ,而不要写 master ,然后读 slave ,因为这可能会引起问题。

Redis 的官网有提到将来可能会支持强一致性, Redis 的 github repo 上面也相关的实验性质的 branch 存在,有兴趣的话可以找找看。

huangz

from redis.

fengchen8086 avatar fengchen8086 commented on July 17, 2024

看到了,谢谢!

from redis.

huangzworks avatar huangzworks commented on July 17, 2024

:)

from redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.