Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long observeChanges call during login

We are seeing very slow login response times on our Meteor app. As load approaches 200 logins/minute the observeChanges calls become quite slow:Login method

ObserveChanges large

As loginWith<service> is part of Meteor core, this problem seems difficult to debug. Note that we only see these slow response times once the app hits 100-200 logins/min second. When there is less load on the app the observeChanges only take a few ms. Any idea what could be causing this?

EDIT: Added a stack trace with the slow items expanded: ObserveChanges large

like image 612
Max Ferguson Avatar asked Nov 12 '15 00:11

Max Ferguson


1 Answers

Looking at your screenshot, it looks like you've defined a custom publication for returning individual user details. As a troubleshooting step, if you're not interested in this query being reactive, try disabling reactivity:

Meteor.publish('currentUser', function () {
  return Users.find({
    _id: this.userId
  }, {
    fields: {
      emails: 1,
      registered_emails: 1,
      services: 1,
      isPremium: 1,
    },
    reactive: false,
  });
});

To take things further (if you want to keep things reactive), you might want to look into leveraging Meteor 1.3's poll/diff tweaking capabilities, to see if that makes a difference. So instead of relying on the oplog for your user publication, try disabling it for that specific query, and tweak the pollingIntervalMs and pollingThrottleMs options. So something like:

Meteor.publish('currentUser', function () {
  return Users.find({
    _id: this.userId
  }, {
    fields: {
      emails: 1,
      registered_emails: 1,
      services: 1,
      isPremium: 1,
    }
  }, {
    disableOplog: true,
    pollingThrottleMs: 10000, 
    pollingIntervalMs: 10000,
  });
});
like image 121
hwillson Avatar answered Nov 16 '22 03:11

hwillson