Sample of distributed messaging system based on Redis pub/sub Developed and tested on Node 5.1.0.
git clone git@github.com:rvinokurov/redis-distributed-messaging.git
cd redis-distributed-messaging
npm i
Entire log's output presents in bunyan format, so you need to install bunyan globally:
npm i -g bunyan
First, start master node. --flush
option clears all info about running nodes in redis and kills all running nodes:
node app.js --flush | bunyan
Then, add some count of listener nodes by running next command several times:
node app.js | bunyan
node app.js --getErrors | bunyan
- redis - redis connection parameters
- MessageGenerator
- sendInterval - interval to send stub messages
- deliveryTimeoutTime - Time to wait for delivery message response from node. On timeout removes from node list
- sendNextMessageOnDelivery - if true, every next message sends when delivery response recieved on timeout. Otherwise every next message sends with fixed interval
sendInterval
- NodeManager
- pingInterval - fixed interval to send
ping
to closest next node. Each node pings next node clockwise
- pingInterval - fixed interval to send
- clearErrorQueue
- concurrency - number of parallel LPOP requests to redis
- MessageEmitter
- maxListeners - number of maxListeners on each channel. Best value depends on setInterval value and listener nodes count
- Migrate to Babel
- Use
Promise
(Bluebird) insteadasync
module and ES7async/await
- Add comments all public methods
- Add unit tests, using Mocha test framework, Chai, Sinon
- Add highload benchmarks