0

I have a C application that inserts data directly to the database of my Meteor application. The app works fine (withoud delays) when I run it in development mode (with "meteor"). However, if I run the app as a node app (bundled) and with external MongoDB, there's an annoying delay in screen updates (5-10s).

I have noticed some previous discussions about this:

Questions:

  1. Is there any other way than building a server-side API for doing the db inserts through Meteor?
  2. Why the delay is only when using external MongoDB?
  3. Is there a way in Meteor to shorten this database polling interval?
Community
  • 1
  • 1
tuomas-p
  • 141
  • 7

1 Answers1

2

You need to enable oplog tailing. Without oplog tailing, when your C program makes a database write, the Meteor server doesn't realise anything has changed until it polls MongoDB again. With oplog tailing, it can pick up the changes much more quickly and efficiently. In development mode, oplog tailing is enabled automatically, but for production it needs some additional setup.

  1. Your MongoDB must be set up as a replica set (a replica set of one node does work).
  2. You have to pass in a mongo URL for the replica set's local database with the environment variable MONGO_OPLOG_URL.

For more information, see this article.

user3374348
  • 4,101
  • 15
  • 29