I tried to find what in my application that takes so much CPU usage and why I get so long waiting times so I started to log some stuff in my application. When I logged every part in my application I ran into this:
var updateTime = process.hrtime();
Nightclubs.update({_id: nightclubId}, {$push: { guests: {
value: value,
currentGuestAmount: currentGuestAmount+value,
date: thisEntryDate.toDate(),
gender: gender,
age: age,
guard: guardId
}}})
var updateDiff = process.hrtime(updateTime);
Later in the method I log this time like this:
console.log('update benchmark took %d nanoseconds', updateTime[0] * 1e9 + updateTime[1]);
Which result in this:
update benchmark took 1084353904561267 nanoseconds
Yep… That is 1.8 WEEKS… This is really weird since the method in total takes 916589992 nanoseconds, or 0.91 seconds (which still is a bit too long)
Does any one have any clue about this?
PS, A bit of details on what data I insert:
guests: { type: Array, defaultValue: [] },
'guests.$': { type: Object },
'guests.$.value': { type: Number },
'guests.$.currentGuestAmount': { type: Number },
'guests.$.date': { type: Date },
'guests.$.age': { type: Number },
'guests.$.gender': { type: String },
'guests.$.guard': { type: String },