Hello, My app showing very high CPU usage with single user only, whenever i do any insert or update cpu goes 70-80% or sometimes 100%.
Meteor Version: 1.6.0.1
I am using reywood:publish-composite
, matb33:collection-hooks
for db relations and doing some subscription using Iron router controller as follow:
waitOn (){
if( Meteor.userId() && typeof navigator != 'undefined'){
let userId = Meteor.userId();
if(navigator && navigator.onLine )
{
return [
Meteor.subscribe('events', userId,{
onReady: function () { }
}),
Meteor.subscribe('notificationlist',userId,{
onReady: function () { }
}),
];
}
}
}
Publications:
Meteor.publishComposite('events', userId => {
return {
find (){
let userId = this.userId || "";
return Invites.find({userId});
},
children: [{
find (invite){
return Events.find({_id: invite.eventId});
},
children: [{
find (event){
return Posts.find({eventId: event._id});
},
children: [{
find (post){
return Meteor.users.find({_id: post.userId}, {fields: {
'profile.firstName': 1,
'profile.lastName': 1
}});
},
}, {
find (post){
return EventImages.find({postId: post._id,imageId: {$exists : true}});
},
}, {
find (post){
return Comments.find({postId: post._id});
},
children: [{
find (comment){
return Meteor.users.find({_id: comment.userId}, {fields: {
'profile.firstName': 1,
'profile.lastName': 1
}});
},
}],
}],
},{
find (event){
return Groups.find({eventId: event._id});
},
}, {
find (event){
return Invites.find({eventId: event._id});
},
}, {
find (event){
return EventImages.find({eventId: event._id});
},
}, {
find (event){
return Activities.find({eventId: event._id});
}
}, {
find (event){
return EventImages.find({eventId: event._id,imageId: {$exists : true}});
},
}],
}],
};
});
Meteor.publishComposite('notificationlist', userId => {
var status = ['no reply'];
var userId = this.userId || "";
inviteListData = Events.find({creating: true});
var eventListRecords = inviteListData.map(function(p) {
return p._id;
});
var inviteList = Invites.find({userId: userId, inviteStatus: {$in: status},eventId:{$nin: eventListRecords}});
var eventList = inviteList.map(function(p) {
return p.eventId;
});
return {
find() {
return Notificationscenter.find({
eventId: {
$in: eventList
},
cleredUsers: {
$nin: [userId]
},
senderId: {
$nin: [userId]
},
$or: [{
userId: "0"
}, {
userId: userId
}]
});
},
children: [{
find (notification){
return Invites.find({_id: notification.inviteId});
},
}, {
find (notification){
return Meteor.users.find({_id: notification.senderId});
},
}],
}
});
I have other publications as well, I am rendering all my templates under events template except the login and login page is working correctly as it have no relational subscription but when i logged in all templates and subscription get executed that making cpu high usage. Whenever i do any update/insert into Invites
, cpu go high with single user.
I have routing for login and events page. For events inner pages i am using params to display active content like all templates get rendered once and changing the views of app based on params.
App is working fine on local machine(MAC) but when i deployed on Galaxy with 2GB container size, it showing High CPU usage or 100% that causing app unresponsive/crashed.
Please advice.
Thanks