Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would a rails 5 upgrade drastically increase database CPU usage?

I upgraded a production app from rails 4 to rails 5 a few days ago, and I have seen a big increase in CPU utilization on my RDS postgresql instance. There does not seem to be any associated increase in database requests or decrease in speed.

What could cause that? What can I do to bring CPU utilization back down while still using Rails 5?

The image below shows CPU utilization on the RDS instance. The time of the upgrade is just to the left of the 11/09 line.

RDS Cpu utilization

like image 287
nbrustein Avatar asked Nov 12 '16 02:11

nbrustein


1 Answers

We eventually tracked this down to an issue in activerecord: https://github.com/rails/rails/issues/27201

Basically, since changed? was sometimes erroneously set to true, we were doing more queries in rails 5 than in rails 4, and we were mis-reading the reports in RDS, so we had not identified the increase in queries.

like image 182
nbrustein Avatar answered Sep 20 '22 08:09

nbrustein