4

I need to test connection between a server located in my own datacenter and an Amazon RDS instance. I've tried with

time telnet <dns-of-my.instance> 3306

but it tracks the time since i've issued the command, until i've ended it, which is not relevant.

Are there any ways of measuring this?

Alex
  • 287
  • 2
  • 9
  • 17

4 Answers4

15

My answer does not assume that ICMP ping is allowed, it uses TCP based measures. But you will have to ensure there are security group rules to allow access from the shell running the tests to the RDS instance

First, ensure some useful packages are installed

apt-get install netcat-openbsd traceroute

Check that basic connectivity works to the database port. This example is for Oracle, ensure you use the endpoint and port from the console

    nc -vz dev-fulfil.cvxzodonju67.eu-west-1.rds.amazonaws.com 1521

Then see what the latency is. The number you want is the final one (step 12)

sudo tcptraceroute dev-fulfil.cvxzodonju67.eu-west-1.rds.amazonaws.com 1521

traceroute to dev-fulfil.cvxzodonju67.eu-west-1.rds.amazonaws.com (10.32.21.12), 30 hops max, 60 byte packets
 1  pc-0-3.ioppublishing.com (172.16.0.3)  0.691 ms  3.341 ms  3.400 ms
 2  10.100.101.1 (10.100.101.1)  0.839 ms  0.828 ms  0.811 ms
 3  xe-10-2-0-12265.lon-001-score-1-re1.interoute.net (194.150.1.229)  10.591 ms  10.608 ms  10.592 ms
 4  ae0-0.lon-001-score-2-re0.claranet.net (84.233.200.190)  10.575 ms  10.668 ms  10.668 ms
 5  ae2-0.lon-004-score-1-re0.claranet.net (84.233.200.186)  12.708 ms  12.734 ms  12.717 ms
 6  169.254.254.6 (169.254.254.6)  12.673 ms * *
 7  169.254.254.1 (169.254.254.1)  10.623 ms  10.642 ms  10.823 ms
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * 10.32.21.12 (10.32.21.12) <syn,ack>  20.662 ms  21.305 ms

A better measure of "latency" might be "the time a typical transaction takes with no or little data to transfer". To do this, write a script element that does this in a loop, maybe 1000 times and then time it with a high precision timer. But the exact details of this vary according to your needs

Vorsprung
  • 32,923
  • 5
  • 39
  • 63
6

Time the query. RDS must be hosting a SQL database server, so issue a trivial SQL query to it and time the execution.

For example, if your RDS instance is PostgreSQL, connect using psql and enable \timing.

psql -h myhost -U myuser

postgres=> \timing
Timing is on.
postgres=> SELECT 1;
 ?column?
----------
        1
(1 row)

Time: 14.168 ms

The latency is 14.168 ms in this example. Consult the manual for timing your specific SQL server implementation.

Quolonel Questions
  • 6,603
  • 2
  • 32
  • 33
0

Usually RDS instances do not respond to ICMP protocols, so we can use TCP protocols for testing, make sure your server's IP is in the white list of the RDS firewall before testing.

So we can use hping3.

Hping3 is a command-line packet analyzer, packet crafter and testing tool for network administrators and penetration testers.

sudo apt-get install hping3

Then run your test like 5 times.

sudo hping3 -S -p <RDS-port> <RDS-endpoint> -c 5

Example:

ubuntu@ip-172-30-0-70:~$ sudo hping3 -S -p  3306 my.ap-northeast-1.rds.amazonaws.com -c 5
HPING my.ap-northeast-1.rds.amazonaws.com (ens5 54.95.xxx.xxx): S set, 40 headers + 0 data bytes
len=46 ip=54.95.xxx.xxx ttl=253 DF id=0 sport=3306 flags=SA seq=0 win=29200 rtt=3.8 ms
len=60 ip=54.95.xxx.xxx ttl=253 DF id=0 sport=3306 flags=SA seq=0 win=28960 rtt=0.0 ms
len=134 ip=54.95.xxx.xxx ttl=253 DF id=19591 sport=3306 flags=AP seq=0 win=227 rtt=0.0 ms
len=52 ip=54.95.xxx.xxx ttl=253 DF id=19592 sport=3306 flags=A seq=0 win=235 rtt=0.0 ms
len=63 ip=54.95.xxx.xxx ttl=253 DF id=19593 sport=3306 flags=AP seq=0 win=235 rtt=0.0 ms

--- my.ap-northeast-1.rds.amazonaws.com hping statistic ---
1 packets transmitted, 5 packets received, -400% packet loss
round-trip min/avg/max = 3.8/3.8/3.8 ms
Vincent Sit
  • 2,214
  • 1
  • 24
  • 27
-1

Use ping. You will need to enable ping on your EC2 instance per this answer.

Ping will provide a time for each ping in milliseconds:

ping 34.217.36.7
PING 34.217.36.7 (34.217.36.7): 56 data bytes
64 bytes from 34.217.36.7: icmp_seq=0 ttl=227 time=68.873 ms
64 bytes from 34.217.36.7: icmp_seq=1 ttl=227 time=68.842 ms
64 bytes from 34.217.36.7: icmp_seq=2 ttl=227 time=68.959 ms
64 bytes from 34.217.36.7: icmp_seq=3 ttl=227 time=69.053 ms
snide
  • 1
  • 1
    your answer is valid only for icmp requests to EC2 instances, not RDS – Alex Mar 19 '18 at 16:45
  • 1
    @Alex it depends what you mean by "latency". The time for a round trip by a ICMP packet is probably similar to a TCP packet time – Vorsprung Mar 19 '18 at 16:47
  • @Vorsprung it doesn't depend on what anyone means by anything. Snide's answer is completely irrelevant to the question, unless shouting a different definition of latency at your screen can somehow make RDS instances accept ICMP packets. – toon81 Nov 14 '18 at 13:26