Skip to content

Redis Oplog implementation to fully replace MongoDB Oplog in Meteor

License

Notifications You must be signed in to change notification settings

megawebmaster/redis-oplog

 
 

Repository files navigation

Welcome to Redis Oplog

LICENSE: MIT

Build Status

RedisOplog

A full re-implementation of the Meteor's MongoDB oplog tailing. This time, reactivity is controlled by the app, opening a new world into building reactive applications, highly scalable chat apps, games, and added reactivity for non-persistent data.

Incrementally adoptable & works with your current Meteor project.

Difference from cultofcoders:redis-oplog

This package uses ioredis as its Redis client which has full support of Redis including Sentinel. Thanks to that you can achieve high availability of Redis cluster and configure connection to your needs.

Installation

meteor add megawebmaster:redis-oplog

IMPORTANT!

To make sure it is compatible with other packages which extend the Mongo.Collection methods, make sure you go to .meteor/packages and put megawebmaster:redis-oplog as the first option.

Configure it via Meteor settings:

// settings.json
{
    ...
    "redisOplog": {}
}

// default full configuration
{
  ...
  "redisOplog": {
    "redis": {
      "port": 6379, // Redis port
      "host": "127.0.0.1" // Redis host
    },
    "retryIntervalMs": 10000, // Retries in 10 seconds to reconnect to redis if the connection failed
    "mutationDefaults": {
        "optimistic": true, // Does not do a sync processing on the diffs. But it works by default with client-side mutations.
        "pushToRedis": true // Pushes to redis the changes by default
    },
    "debug": false, // Will show timestamp and activity of redis-oplog.
  }
}

To see what you can configure under "redis": {} take a look here: https://github.com/luin/ioredis#connect-to-redis

meteor run --settings settings.json

Notes

RedisOplog is fully backwards compatible, so there won't be any change in how you use Meteor, unless you want to fine-tune your application for absolute performance.

RedisOplog does not work with insecure package, which is used for bootstrapping your app.

Also make sure that your production system does not generate MONGO_OPLOG_URL to disable MongoDB Oplog tailing. If you need to forcibly disable it please run meteor add disable-oplog.

Stats

If you are interested in viewing how many observers are registered or memory consumption:

meteor shell
import { RedisOplog } from 'meteor/megawebmaster:redis-oplog';

// works only server-side
RedisOplog.stats()

The levels of scaling reactivity

  1. Just add RedisOplog, you will already see big performance improvements
  2. Fine-tune your reactivity by using custom namespaces and channels
  3. Implement your own custom reactivity by using Redis Vent

If you are using Optimistic UI (Latency Compensation) in your application, you should give this a read.

Find out what RedisOplog does behind the scenes

Find out how you can use the advantages of Redis Oplog to make your app very performant.

Find out how you can hook into redis events to customize, when it fails.

Find out how you can customize your reactivity and enable it across multiple languages/microservices with ease.

If you have different workers/services that perform updates to mongo and they exist outside Meteor, you can still trigger reactivity for the Meteor instances with a few lines of code.

About

Redis Oplog implementation to fully replace MongoDB Oplog in Meteor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%