RobinQu / datastack

Drop-in RESTful middlewares for koa
http://robinqu.github.io/datastack
39 stars 4 forks source link

cluster support #17

Closed RobinQu closed 10 years ago

RobinQu commented 10 years ago

At present, single node mode:

app events -> notifier -> clients

This could cause a number of clients misses message when they connect to a different notifier.

A possible solution for multi-node deployments:

app events ->  broker - > notifier 1 -> clients (group1)
                                    -> notifier 2 - > clients (group2)

A broker could be

RobinQu commented 10 years ago

Implmentation notes:

  1. app.emit() should only be used to transmit local event within an StackApp or koaapp isolated in a single process.
  2. app.sync() will emit the messages and inform the cluster master and then propagate the messages to other workers both inside and outside the current cluster.
  3. Messages are synced from other workers won't propagate further. That means, app.sync() is the only means to make a message received by all workers across arbitrary machines.
RobinQu commented 10 years ago

Sync of messages are slowed down by the polling methods employed by voka. This will be discussed in https://github.com/RobinQu/voka/issues/2