Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku shared db vs Amazon RDS Performance

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?

like image 433
samvermette Avatar asked Oct 09 '11 02:10

samvermette


People also ask

How can I improve my RDS performance?

DB instance RAM recommendations An Amazon RDS performance best practice is to allocate enough RAM so that your working set resides almost completely in memory. The working set is the data and indexes that are frequently in use on your instance. The more you use the DB instance, the more the working set will grow.

Is Heroku Postgres good?

Heroku Postgres is an easy, low-cost way to get started with a relational database on the Heroku platform. This open-source database is also the most effective service for developers looking to build engaging apps.

What is the maximum number DB instances can user can run with Amazon RDS?

For Oracle, you set the maximum number of user processes and user and system sessions. If the default value calculation results in a value greater than 16,000, Amazon RDS sets the limit to 16,000 for MariaDB and MySQL DB instances.

Can we increase IOPS in RDS?

You can modify the settings for a DB instance that uses Provisioned IOPS SSD storage by using the Amazon RDS console, AWS CLI, or Amazon RDS API. Specify the storage type, allocated storage, and the amount of Provisioned IOPS that you require.


1 Answers

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).

enter image description here

like image 162
samvermette Avatar answered Oct 03 '22 04:10

samvermette