I’m in the process of moving all my data from Heroku’s shared db to Amazon RDS. Before switching everything over to RDS, I ran some tests locally to make sure my app works fine with it. These tests clearly slow that query time is slower on RDS. For the exact same request, I get:
On Heroku, with heroku shared db:
Completed 200 OK in 98ms (Views: 0.7ms | ActiveRecord: 56.0ms)
Locally, with RDS db instance
Completed 200 OK in 253ms (Views: 0.7ms | ActiveRecord: 127.9ms)
The ActiveRecord times are what I’m worried about here. Am I missing something? Heroku clearly states this about their shared db:
Shared databases are suitable for staging, testing, and low-scale
production applications.
And yet it seems to be faster than this RDS instance I’m paying 80$/month for. Is heroku’s shared db running locally? Because it’s pretty obvious to me that about any database running locally inside my heroku app is going to be faster than any db that lives outside of it. Amazon says that any query taking more than 10ms is considered as a “slow query”. But right now it seems that every query is gonna take at least 25ms for the roundtrip alone from the app to amazon’s server + the actual query time. Or am I missing something?
From what I understand, Heroku EC2 instances run in the East availability zone, so creating an RDS instance in that same zone is pretty much like giving it a local database (I believe that’s how heroku’s shared databases work as well).
After setting up a staging environment for my app directly on Heroku and connecting it to my RDS instance, query times were much faster than when I tested it locally (where each SQL query had to make a roundtrip from my local machine to the RDS servers).
The only minor thing that’s left unanswered is how to determine in which particular availability sub-zone my heroku app is running, so I can match it with my RDS instance (although it probably doesn’t matter as much as the global availability zone).