Connecting to a local database on the same EC2 instance has a low latency, but to RDS things get really high. See results below.
time mysql -u root -proot -h localhost -e 'show databases'
+--------------------+
| Database |
+--------------------+
| information_schema |
| biblical |
| mysql |
| performance_schema |
| phpmyadmin |
| shop |
+--------------------+
real 0m0.005s
user 0m0.003s
sys 0m0.000s
but connecting to my amazon RDS instance in the same availability zone give me this
+--------------------+
| Database |
+--------------------+
| information_schema |
| biblical |
| mysql |
| performance_schema |
| phpmyadmin |
| shop |
+--------------------+
real 0m0.090s
user 0m0.000s
sys 0m0.000s
.005 to 0.090 has a large impact on my application's performance (Magento), and this was for a simple query. If performing a more CPU intensive query, this could get way high. Is there anyway to improve this ??
If performing a more CPU intensive query, this could get way high
: This assumption is not necessarily correct, as you don't know what is causing the higher latency. This can very well be a constant time factor that is completely independent of the complexity of the query, e.g. overhead in the authorization phase. Remember, yourtime
command times everything, from name resolution to establishing the network connection, authorization, query time and result transmission time.