Meteor: server-side db insert delays

前端 未结 1 609
误落风尘
误落风尘 2021-01-13 19:07

Interesting issue: I\'ve got a MongoDb collection that I\'m updating server side, with Meteor client-side hooks into the same collection. I\'m noticing ~10 second delays for

1条回答
  •  醉梦人生
    2021-01-13 19:40

    The meteor mongo driver polls for changes in Mongo every 10 seconds to ensure that data that's written into it from outside Meteor makes its way down to the client. Here's the relevant source code:

      // every once and a while, poll even if we don't think we're dirty,
      // for eventual consistency with database writes from outside the
      // Meteor universe
      var intervalHandle = Meteor.setInterval(
        _.bind(self._ensurePollIsScheduled, self), 10 * 1000 /* 10 seconds */);
        self._stopCallbacks.push(function () {
        Meteor.clearInterval(intervalHandle);
      });
    

    This behavior is likely to change per Matt Debergalis, one of the core devs:

    This polling is so that Meteor will notice DB changes that didn't come through the Meteor server process.

    Many apps don't need this, though. We're considering ways to disable it. We also have a more efficient implementation in the hopper.

    0 讨论(0)
提交回复
热议问题