/meteor-cluster

Smarter way to run cluster of meteor nodes

Primary LanguageJavaScript

This is a archived project

Meteor Cluster is now retired & Meteor's Collection implementation implementation with Oplog support can be used to run a cluster of Meteor nodes.

meteor-cluster Build Status

Smarter way to run cluster of meteor nodes

Meteor is not a toy anymore. People keen to build enterprise apps on top of the meteor. So people need to run cluster of meteor nodes for several reasons.

But when running cluster of nodes, meteor is not realtime anymore(between nodes). It get synced but takes few seconds.

Here comes the solution - meteor-cluster

Meteor Cluster in Action

Installation

just run mrt add cluster

Redis

meteor-cluster uses redis as the communicate channel between nodes. It uses pub/sub functionality of redis. So you need to have redis-server running.

If you are new to redis, read this guide

Configurations

meteor-cluster needs to know

  • how to connect with redis
  • what collections it needs to sync

It just a two lines of configuration. Add following inside you server code.

Meteor.startup(function() {
    Meteor.Cluster.init(); //assumes you are running redis-server locally
    Meteor.Cluster.sync(Posts, Notifications, Comments); //these are my collections
});

How to scale

Just fire up new nodes and it just works.

Tests

  • start redis-server before testing
  • mrt test-packages ./

API

Meteor.Cluster.init(redisConfig)

Initialize and connect to redis.

  • redisConfig - null or {port: 6337, host: "localhost", auth: null, db: null}
  • alternatively you can pass redis config via CLUSTER_URL env variable
  • CLUSTER_URL formart: redis://redis:<password>@<host>:<port>

Meteor.Cluster.sync(collections...)

Sync given set of collection between nodes

  • collections... - Collections defined as list of arguments