Hacker News new | ask | show | jobs
by _Lemon_ 5191 days ago
Redis can only perform asynchronous replication because it uses a single thread. It cannot block the main thread waiting for the network and have acceptable performance. This makes replication as good as "appendfsync no" as you have no guarantees as to what happened on the network write.

The upside of the design is that it makes things simple (e.g., transactions, append only file).

(This is my understanding, please correct me if I'm wrong!)

1 comments

Yes it is correct that asynchronous replication is the only way Redis handles replication, however replication and durability are still in topic: if the master burns in fire, the slave will contain your data ;)

However there are people that turn Redis async replication into synchronous replication with a trick: they perform:

    MULTI
    SET foo bar
    PUBLISH foo:ack 1
    EXEC
Because PUBLISH is propagated to the slave if they are listening with another connection to the right channel they'll get the ACK from the slave once the write reached the slave. Not always practical but it's an interesting trick.