TonyTakeshi
TonyTakeshi

Reputation: 5929

Amazon RDS batch insert slower than local database?

I wrote a node program that batch insert to database and do a console log for every completed insert.

function insert(){
    var sql = "insert into todo (user, content) values (xx, xx);" +
              "insert into todo (user, content) values (xx, xx);" +
              "insert into todo (user, content) values (xx, xx);" +       
    (.... 4000 lines of insert)

    db.insert(sql,function success(){
        console.log('done');
    });
}

for(i=0;i<10000;i++){
    insert();
}

I have 2 setup of this:

1) Local machine to local DB. 

2) Amazon EC2 Micro Instance to Amazon RDS Micro Instance from same region

*Both my.cnf leave to default with only max_allowed_packet=500m set.

The result is by the time RDS complete one insert, my local machine has completed 24 insert. I tried to upgrade my RDS to small instance, it make no different.

My question is why is amazon rds slower in this case. Any solution for this?

Upvotes: 1

Views: 2128

Answers (1)

j0nes
j0nes

Reputation: 8109

I think the problem might be related to the micro instance performance. After some testing, we moved completely away from micro instances and switched to small instances. On the other hand, I have not found any problems regarding the RDS speed, even with small instances.

Have a look at how the EC2 micro instances work and where they should be used: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts_micro_instances.html

From how I understand your test case, your setup mostly looks like the second figure, and this should not be suitable for micro instances. Try using a small instance and compare the results there. Even if it is still slower than on your local machine, you will have comparable results then.

Upvotes: 2

Related Questions