CPU regularly spikes with time interval without subscription/publication

Hi, everyone.

I have a collection of roughly 50K documents in a DB. And this collection is not used for subscription/publication. I use this only with a method call to retrieve data.

However, I figured out that the meteor server’s CPU regularly spikes up depending on the amount of data in the MongoDB. FYI, Meteor server and MongoDB are hosted on separate AWS EC2 instances.

It seems that meteor fetches all the data when the collection is declared and holds it for poll-and-diff, which causes CPU to hit high regularly. How can I stop this?

I appreciate any comments!
Best regards!

~~~~~~~~~~~~~ update ~~~~~~~~~~~~~~
The issue is solved by implementing a different pattern. Because I do not need reactivity for this collection, I simply declared and initialized the collection from the raw database by using MongoInternals. It has a different syntax, (eg. there is no cursor.fetch() which makes it a bit tricky if you want to return the collection docs through method calls… Also you need to implement collection hooks on your own.) but the CPU is now on zero to 2 percent at most. Before it reached up to 30 percent on a single node on M4.large EC2 instance.
Just not using pub-sub pattern didn’t solve my problem. (By the way, I am sure that the oplog tailing is working properly when I see the other reactivity-based collections. And the MongoDB replicaSet is also working properly.)
Hope this can be a reference to anyone with similar concerns.
:slight_smile:

You need to make sure that you’ve specified a Mongo oplog URL on your Meteor server and that your query is oplog tailable https://kadira.io/academy/meteor-performance-101/content/optimize-your-app-for-oplog

1 Like

Hi! Thank you for your reply.
I have checked that the oplog is working fine.
I also noticed that the CPU fluctuation happens with all the find queries commented out. (Seems to happen when declared).

I am using meteor version 1.1.0.3 and things were the same when I temporarily updated to version 1.3.x so I rollbacked to older version.

I am guessing some packages I am using could be a culprit.

Thank you again!