Question about redis-oplog

Hello,
I have a question about redis-oplog.

I have 2 meteor applications connected to the same mondodb replica set but different database

I have installed one redis server on the same server where my both apps are running. Both apps are conencted to the same redis server.

It seems from the logs that when I update a doc in one application the other app is receiving the update

This is my pm2 logs of my 2 apps :

It feels strange to me, I do not want one app to receive info from the other app (they are different companies). Is this a normal behavior ?

I would think that redis-oplog would add a prefix to the channels with the name of the mongo database or something like this.

I have tried to add namespace globally but this does not seems to help

"redisOplog": {
          "redis": {
            "port": 6379,
            "host": "127.0.0.1"
          },
          "retryIntervalMs": 30000,
          "mutationDefaults": {
              "namespace": 'demo',
              "optimistic": false, 
              "pushToRedis": true
          },
          "debug": true
        },

And I also read in the docs that namespace are ignored when working with _id in mongo docs.

What do you think ? Should I have one redis server for each app ?

It can be done with one redis DB.

But for your use case, it is simpler to use different redis DB per company/app

One redis server can host multiple redis DBs

1 Like

Thanks a lot for your help.
I did not know the concept of database inside Redis.
I have tried to configure the Meteor.Settings of my first app like this :

 "redisOplog": {
          "redis": {
            "port": 6379,
            "host": "127.0.0.1",
            "database": 1
          }
        },

and my second app like this :

 "redisOplog": {
          "redis": {
            "port": 6379,
            "host": "127.0.0.1",
            "database": 2
          }
        },

but the result is the same : I receive an update event in my 2 applications.

Is this the right way to disntinguish databases ?

Some reference (advise to use different server) : Sharing a Redis database between multiple apps · Issue #178 · cult-of-coders/redis-oplog · GitHub

I was able to solve my problem by running 2 different redis server on my linux machine 1 server per app using this guide : Correct way to run multiple Redis instances on Linux | by Viacheslav Starikov | Medium

We also reuse Redis instances between environments by using separate databases. I’m not sure about the port/host/database config, we just use a redis://-based URL in the url field and a /N suffix.

1 Like

Replace database with db

Thanks, I tried :

First app :

"redis": {
            "url": "redis://127.0.0.1:6379/0",
          }

Second app :

"redis": {
            "url": "redis://127.0.0.1:6379/1",
          }

And even with this both app are receiving updates, which is not what I want

I also tried :

"redis": {
            "port": 6379,
            "host": "127.0.0.1",
            "db": 1
          },

Same problem.

I have ran into this thread : https://stackoverflow.com/questions/16221563/whats-the-point-of-multiple-redis-databases

They advise to use separate instance/server for different database. I think for the moment i will use 2 instances on 2 different ports.
Thanks @radekmie and @rjdavid

We do have two Redis instances: one for production and one for non-production environments (more than 5). I agree that performance wise it’d be better to have one each, but… The production one uses roughly 2% CPU and 60MB of RAM (and we use it for Apollo Server cache as well).

Hello,
I would also prefer to have only one server for all my instances (not for performance reason but more for maintenance and simplicity of management reasons) but i was not able to isolate messages as you did. I tried using different db but when I change a document in one app I saw the other app receiving the update notification as well.

I’m wondering now: @rjdavid are you using oplogtoredis or changestream-to-redis? Because we are, and maybe there’s a problem with the builtin Redis publisher?

My test are with GitHub - cult-of-coders/redis-oplog: Redis Oplog implementation to fully replace MongoDB Oplog in Meteor
If needed we can do a screen sharing session and I can show you the behavior I have. Let me know if I can help.

We are using only redis-oplog. I need to ask our DevOps what they did since I realized we moved all our instances to ioredis and are running a forked version. For what it’s worth, we have a group of apps using 7 shared redis DBs in production.