登录期间长时间调用 observeChanges
Long observeChanges call during login
我们发现 Meteor 应用程序的登录响应时间非常慢。随着负载接近 200 logins/minute,observeChanges 调用变得相当慢:
由于 loginWith 是 Meteor 核心的一部分,这个问题似乎很难调试。请注意,只有当应用达到 100-200 logins/min 秒 时,我们才会看到这些缓慢的响应时间。当应用程序负载较少时,observeChanges 只需要几毫秒。知道是什么原因造成的吗?
查看您的屏幕截图,您似乎定义了一个自定义发布来返回单个用户的详细信息。作为故障排除步骤,如果您对该查询的反应性不感兴趣,请尝试禁用反应性:
Meteor.publish('currentUser', function () {
return Users.find({
_id: this.userId
}, {
fields: {
emails: 1,
registered_emails: 1,
services: 1,
isPremium: 1,
},
reactive: false,
});
});
为了更进一步(如果你想让事情保持被动),你可能想研究利用 Meteor 1.3's poll/diff tweaking capabilities,看看这是否有所作为。因此,不要依赖于您的用户发布的 oplog,请尝试为该特定查询禁用它,并调整 pollingIntervalMs
和 pollingThrottleMs
选项。所以像:
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,
});
});
我们发现 Meteor 应用程序的登录响应时间非常慢。随着负载接近 200 logins/minute,observeChanges 调用变得相当慢:
由于 loginWith 秒 时,我们才会看到这些缓慢的响应时间。当应用程序负载较少时,observeChanges 只需要几毫秒。知道是什么原因造成的吗?
查看您的屏幕截图,您似乎定义了一个自定义发布来返回单个用户的详细信息。作为故障排除步骤,如果您对该查询的反应性不感兴趣,请尝试禁用反应性:
Meteor.publish('currentUser', function () {
return Users.find({
_id: this.userId
}, {
fields: {
emails: 1,
registered_emails: 1,
services: 1,
isPremium: 1,
},
reactive: false,
});
});
为了更进一步(如果你想让事情保持被动),你可能想研究利用 Meteor 1.3's poll/diff tweaking capabilities,看看这是否有所作为。因此,不要依赖于您的用户发布的 oplog,请尝试为该特定查询禁用它,并调整 pollingIntervalMs
和 pollingThrottleMs
选项。所以像:
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,
});
});