I’m trying to pinpoint sources of CPU spikes on my Galaxy instances. I figured a good place to start would be going to Meteor APM → Methods → sort by Compute Time. Every single method at the top are basically HTTP calls with callback functions.
According to the Kadira docs, the Compute Time
metric is defined as: “Time spent on CPU-intensive tasks inside a method (e.g. time spent sorting and calculating some value).”
Here’s my highest compute time method:
Meteor.methods({
getData(url) {
this.unblock()
return new Promise((resolve, reject) => {
HTTP.get(url,function(error, response){
if(!error){
resolve(response.data)
} else if (error){
reject(new Meteor.Error('getData failed',JSON.stringify(error)))
}
})
})
}
})
All of these methods coming back as high CPU use return new Promise
in their underlying structure. Is that where I’m running into issues? Is this actually locking up my CPU? Or is it just a funky reporting behavior in APM?
If so, what alternatives should I use? This seems like it has the same result – is there any reason Meteor would handle this differently from a Compute Time
perspective?
Meteor.methods({
async getData(url) {
try {
var data = await HTTP.get(url)
return data.data
} catch(err) {
console.log(err)
return 'getData failed'
}
}
})