Skip to content

Connection Internal Delay

0

Hi, I need to understand a technical aspect, that is, when i am querying my RDS from the Windows EC2 instance it returns the query in 500ms, whereas when i query the RDS from my personal laptop it return response in 300ms, How can the connection internal to VPC be delayed compared to Public access. This is a technical question Kindly assist.

2 Answers
1
Accepted Answer

Is the RDS database in the same VPC as the EC2 instance? Does its DNS name resolve to the private IP or public IP when queried from the EC2 instance?

If it's a SQL Server database, you could try connecting to it with SQL Server Management Studio (SSMS) and running the same query repeatedly without disconnecting from the database in between. Does it take the same 500 ms every time, or is the first execution slow and subsequent ones faster? Or is every execution faster when run via SSMS and only slow when executed by your application?

EXPERT
answered a year ago
EXPERT
reviewed a year ago
  • I have used MySQL RDS and is in the same VPC as the EC2, also the DNS works fine as it is easily able to resolve from public host, also the query time is almost the same +-5ms.

    Can you help understanding the reason for the same, why is the query taking less when done from local PC and query is taking more time when done from an EC2 within the same VPC and AZ.? @Leo K

0

The greater distance over the network from on premises can't improve performance, so the reason has to be something different. The most important thing for successful troubleshooting would be to normalise the test conditions to make test results comparable.

Are you using the mysql command line client for your tests both on your on-premises device and on the EC2 instance? If so, try first connecting and logging on to MySQL with it, so that we can eliminate DNS resolution, authentication, and other variables related to establishing the connection from the equation. Once you have the mysql command line utility connected to the database, run the same query repeatedly and consecutively (without disconnecting), at least 5 times, from the on-premises location, and afterwards, repeat that from the EC2 instance.

Do all the tests run at the same speed? Meaning does it take circa 300 ms every one of those five times when executed from your laptop, and does it also systematically take circa 500 ms every time it's run from the EC2 instance? Or, does the first of the five queries run slowly and the other four attempts run faster?

Also, try simply pinging the MySQL database's DNS name from the EC2 instance. It doesn't matter whether you even get replies to the pings, but what matters is that the DNS name resolves to a private IP address inside the VPC and not to the public IPs of the RDS database. Your on-premises client connects to the internet-facing public IPs, but the EC2 instance should be connecting to the private IPs inside the VPC.

EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.