gpt4 book ai didi

mongodb - meteor 使用 Mongo Oplog 吗?

转载 作者:可可西里 更新时间:2023-11-01 09:10:36 26 4
gpt4 key购买 nike

如何检查 meteor 是否正在使用我的 mongo 的 oplog?我有一个 mongo 集群,并为我的 meteor 设置了两个环境。

MONGO_URL=mongodb://mongo/app?replicaSet=rs0
MONGO_OPLOG_URL=mongodb://mongo/local?authSource=app

如何检查 opt 日志是否实际在使用中。 Meteor 可以回退到非常低效的查询轮询,但我想看看它是否与 oplog 一起正常工作。

有什么想法吗?

最佳答案

引用 Meteor 的 OplogObserveDriver docs 中的相关位:

How to tell if your queries are using OplogObserveDriver

For now, we only have a crude way to tell how many observeChanges calls are using OplogObserveDriver, and not which calls they are.

This uses the facts package, an internal Meteor package that exposes real-time metrics for the current Meteor server. In your app, run meteor add facts, and add the {{> serverFacts}} template to your app. If you are using the autopublish package, Meteor will automatically publish all metrics to all users. If you are not using autopublish, you will have to tell Meteor which users can see your metrics by calling Facts.setUserIdFilter in server code; for example:

Facts.setUserIdFilter(function (userId) {
var user = Meteor.users.findOne(userId);
return user && user.admin;
});

(When running your app locally, Facts.setUserIdFilter(function () { return true; }); may be good enough!)

Now look at your app. The facts template will render a variety of metrics; the ones we're looking for are observe-drivers-oplog and observe-drivers-polling in the mongo-livedata section. If observe-drivers-polling is zero or not rendered at all, then all of your observeChanges calls are using OplogObserveDriver!

关于mongodb - meteor 使用 Mongo Oplog 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39002192/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com