Use as many re-usable publications as you can [β¦]
Go one step further - split mixed ones into shared and non-shared. Letβs say your publication looks like this:
Meteor.publish('notificationsForUser', userId => {
// Authorization...
return Notifications.find({
$or: [{ type: 'global' }, { type: 'user', userId }]
});
});
Then check if the number of shared documents (here: type: 'global') is large. If so, such a split:
Meteor.publish('notificationsGlobal', () => {
// Authorization...
return Notifications.find({ type: 'global' });
});
Meteor.publish('notificationsForUser', userId => {
// Authorization...
return Notifications.find({ type: 'user', userId });
});
May drastically increase the number of reused observers and, in the end, greatly reduce both DB and server pressure. Once Iβve split such a publication into 4 (mixed ~> global, organisation, month, user) and reduced costs by 30% (we switched to a smaller DB instance and reduced the number of containers).
Just remember - always measure it for yourself!