Does Redis Pub/Sub work with master-slave replication?
In short: yes!
To see this,
start two Redis servers
in master-slave configuration,
then subscribe to channel
foo on the slave:
$ redis-server --port 6379 & $ redis-server --port 6380 --slaveof 127.0.0.1 6379 & $ redis-cli -p 6380 subscribe foo Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "foo"
Now publish something to
foo on the master:
$ redis-cli -p 6379 publish foo bar
You’ll find that this message does arrive at the client subscribed on the slave:
... 1) "message" 2) "foo" 3) "bar"
publish commands are replicated to the slave.
You can see this by
first sending the
to the Redis master
which then becomes a Redis slave
and prints all replicated commands:
$ redis-cli -p 6379 sync Entering slave output mode... (press Ctrl-C to quit) SYNC with master, discarding 76 bytes of bulk transfer... SYNC done. Logging commands from master. "publish","foo","bar"
More by Jim
- Your syntax highlighter is wrong
- Granddad died today
- The Three Ts of Time, Thought and Typing: measuring cost on the web
- I hate telephones
- The sorry state of OpenSSL usability
- The dots do matter: how to scam a Gmail user
- My parents are Flat-Earthers
- How Hacker News stays interesting
- Project C-43: the lost origins of asymmetric crypto
- The hacker hype cycle
- The inception bar: a new phishing method
- Time is running out to catch COVID-19
- A probabilistic pub quiz for nerds
- Smear phishing: a new Android vulnerability