New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPU Spikes #694
Comments
Hi @HuarenYu & @sidorares, You guys seem like experts on node-mysql. Can you please look at this issue and tell me it is a bug with node-mysql or the orm I am using. Either way can you please give me suggestions on how to fix the problem. Thank you in advance for all the help, your help would be much appreciated. |
Could you post results of v8 profiler? See https://github.com/sidorares/node-tick how to start it. If node-tick itself does not work (v8.log format changed couple of times since I released it) you can use *tick-processor tools from node distributions (they are under /deps/v8/tools) |
here is v8 profiler results @sidorares. I batching the results in multiple comments because github said the comment body exceeded the maximum character limit. |
|
|
|
|
I'm afraid that your v8.log is not compatible with node-tick version. Could you upload it somewhere (I know it can be huge, gzipping might help a bit) and I'll try to analyse it |
here is a dropbox link with a zip of the tick file and the v8 log file. https://www.dropbox.com/s/lk67m7hl4yb4z1s/Archive.zip |
thanks again |
@sidorares after looking at the v8 log file, do you think the bug is in the node-mysql module or the node-orm-2 module? |
This is processed v8.log: https://gist.github.com/sidorares/8293807 - my results are different from yours for some reason |
Respectfully I dont think it is the less compiler. Before I started using mysql and the node-orm I was using less. The less compiler did not create any cpu spikes. Also, the project that I am working on uses an asset manager which compiles the less once and stores it in the temp folder. The cpu spikes I am currently seeing last for around 5 minutes. Lastly, I only see the dramatic 99% - 100+% cpu spikes after I hit a webpage that talks to the database. Is their anyway of refining the results or using a different tool to find where the spikes are coming from? |
Are you sure you recorded v8.log during spike? |
@bvallelunga you need to send a log that actually captured the CPU spike you are seeing. The log you sent didn't actually do much but compile less, which sounds like you just started the server and captured a log and sent that, effectively sending a log showing what happens when you start the server instead of what happens when you are seeing the CPU spike. |
i will reprofile my node app |
@sidorares & @dougwilson here a screenshot from atop while a ran my app. |
In your initial post, there is a function assigned to |
i only called that only once, but I call exports.express every request |
Nevermind, I see you are doing this: orm.express(config.orm, {
define: function (db, models, next) {
configure(db, models, next);
}
}); which calls your |
Specifically it seems to be the use of |
this code below was take from node-orm-2 wiki. As you can see the app.use initializes the orm every request. var express = require('express');
var orm = require('orm');
var app = express();
app.use(orm.express("mysql://username:password@host/database", {
define: function (db, models, next) {
models.person = db.define("person", { ... });
next();
}
}));
app.listen(80);
app.get("/", function (req, res) {
// req.models is a reference to models used above in define()
req.models.person.find(...);
}); |
Yes, but it does not call the |
you are right. it doesnt |
i will test this now |
cc @dresende ( orm2 author and node-mysql maintainer ) |
@dougwilson do you see anything else that seems odd or would create problems |
I do not know. I have never used |
@sidorares have you used node-orm before? If so can you take a look at my code and tell me if you see anything wrong? |
thanks for your help @dougwilson |
I don't use it personally but we have projects using orm2+postgres |
@sidorares would you mind sharing this issue with the developers that use |
afaik we haven't seen similar performance issues |
okay, thank you for all your help |
Also, I keep seeing |
i will implement tonight |
@bvallelunga here is the change if you want to test it and see how it changes your usage: https://github.com/dougwilson/node-mysql/commit/f97547f99a06bc1ab1c62d918177b0783fa6eb15 |
@dougwilson I started small benchmark of your branch vs master ( 3 amazon instances - wrk + mysql/http + rds ) - I'll post results soon |
@bvallelunga @sidorares looks like you should use commit https://github.com/dougwilson/node-mysql/commit/b301549763e480ba7d61e38aaabf97eea4e5d5ca instead; my first commit had a calculation error that just broke everything :S |
I think there wasn't a bug after all. It seems after more research that the i/o on my dev box which hosted the node app and mysql was not enough, meaning that the db was offloaded to the CPU |
I'm closing this for now as it seems reasons are external to driver. @bvallelunga If you find evidences proving opposite please reopen |
Node Version: v0.10.23
Mysql Version: 5.5.34-0ubuntu0.12.10.1
Package Version: 2.1.3
I am using an orm called node-orm-2 and I am getting cpu spike just when doing a simple login. Any page I hit that touches the database sends the cpu to 90%+.
The text was updated successfully, but these errors were encountered: