Scale out

Scale out through StackExchange interface and its completors is a feature that was implemented at neffos v0.0.6.

Made after a user feature request* with the five following commits:

Scaling out a neffos app can be achieved by adding just three extra lines of code(!)

  1. Import github.com/kataras/neffos/stackexchange/redis or nats

  2. Initialize the StackExchange, e.g. exc := redis.NewStackExchange(...)

  3. Right after the server := neffos.New add server.UseStackExchange(exc).

Each StackExchange contains its own configuration.

How it works

  1. Each client connected to a neffos namespace is subscribed a channel/subject and unsubscribes itself on namespace disconnection.

  2. Each time a neffos Broadcast is called the message directly goes to the registered StackExchange.Publish method, which takes care to publish the message to the correct channel/subject, so subscribers can be notified about this message.

  3. Each time a subscriber notified for a new message its Conn.Write is responsible to dispatch that message to the client side.

  4. The same pattern is used for one to one messaging and Server.Ask.

Use this feature when you have multiple neffos servers hosted independently for a particular neffos app of yours and you want your app to be able to communicate with all of those neffos servers as one.

Next steps

Last updated