Sql-server – Why is the Amazon RDS instance so slow

amazon-rdsperformancesql server

I currently run a Windows Server with SQL Server Express. I want to follow best practice and separate the application from the database, so I've created an RDS instance and exported my database.

But… it's painfully slow. I'm running a test query from my local machine that selects 12000 rows – it takes less than 1 second against my original setup but 16 seconds against RDS. Surely it can't be question of specification; my small RDS instance actually has a better spec. than my Windows Server.

What could be going on here?

Best Answer

Just a guess as there isn't enough information to really figure this out but it could be network latency. You're saying that local connection to local DB is fast but local to remote DB is slow. All other things being equal the only difference is the network connection between you (local) and the remote DB.

Generally AWS is pretty fast and has a stable network but you might notice latency issues for more chatty protocols. I'm not too familiar with the wire protocol for SQL Server but I know that Oracle for example is a relatively chatty protocol so it could be similar. As such you'll see much better performance when the network connection between the client and the server (the database) are on a low latency network with a minimal amount of hops.

Another issue could be if your local internet connection doesn't have much bandwidth (say a 1 Mb/s DSL) and you try streaming back a lot of rows from the remote database.

You should repeat your test from a Windows instance that's close to the RDS instance. I don't think you're allowed to remote into the RDS instance itself but you should be able to spin up a Windows instance that's in the same availability zone. That should be close enough to what it's like in a real world deployment.

Also, if you're planning on using the remote Amazon RDS instance as the database for an application that's not running on Amazon then you really need to test out the performance in advance. The intended use case is having your application running on EC2 so that you're on a low latency network with the DB. It would still work remotely but the performance will we wildly different.