DEV Community

Franck Pachot for AWS Heroes

Posted on

How far is my AWS region?

Everybody wants to know how far they are from an AWS region. This even when not working in IT: my kids know which AWS region they connect to when playing Fortnite.

New region in Switzerland

I'm back from the AWS Swiss User Group Lausanne where the first topic was the new AWS Swiss region in Zurich. It is on average 10% more expensive than Frankfurt but there are two reasons to go to a region in your country: legal constraints and lower latency.

It can be obvious that connecting within your country is faster. However, on the internet, the fastest way may not be the shortest one. It depends on the internet routes. Let's try it. I live near Lausanne (Switzerland), and will ping an AWS server in the new region eu-central-2 in Zurich (250 km, in Switzerland) and the one I used until now, eu-central-1 in Frankfurt (550 km, in Germany):
The Lausanne-Zurich way should stay in Switzerland and be faster than Lausanne-Frankfurt, right?

Without having to know a server to ping in each region, I can ping the DynamoDB service and show the connect time with with curl -w "%{time_connect}:

Franck:~ $ curl -w "%{time_connect} $name\n" \

healthy: 0.144338

Franck:~ $ curl -w "%{time_connect} $name\n" \

healthy: 0.082063
Enter fullscreen mode Exit fullscreen mode

This is 144 milliseconds to Zurich and 82 milliseconds to Frankfurt, the opposite of what I expected. However, the routes can change. If you run the same to the same destination several times, you may get lower latency:

Franck:~ $ 
for r in eu-central-2 eu-central-1 ; do
for i in {1..10} ; do
curl -w "%{time_connect} $name\n" \

healthy: 0.083545 us-west-1
healthy: 0.083080 us-west-1
healthy: 0.083567 us-west-1
healthy: 0.085773 us-west-1
healthy: 0.064574 us-west-1
healthy: 0.054981 us-west-1
healthy: 0.085418 us-west-1
healthy: 0.059449 us-west-1
healthy: 0.057155 us-west-1
healthy: 0.075989 us-west-1

healthy: 0.096158 us-west-1
healthy: 0.061988 us-west-1
healthy: 0.059302 us-west-1
healthy: 0.048715 us-west-1
healthy: 0.067701 us-west-1
healthy: 0.079070 us-west-1
healthy: 0.057664 us-west-1
healthy: 0.052125 us-west-1
healthy: 0.057473 us-west-1
healthy: 0.065644 us-west-1

Enter fullscreen mode Exit fullscreen mode

Connect time to all AWS regions

I'll ping every DynamoDB service in all AWS regions worldwide and sort them by latency to get a TCP connect.

You need to install curl and jq for that. The connects 10 times to each region and displays the minimum connect time for each:

for i in {1..10} ; do
for name in $(
 curl -s |
  jq -r '.[]|select(.service_name=="Amazon DynamoDB")|.region_id'
 curl -sw "%{time_connect}\n" http://dynamodb.$
done |
 awk '
  t[$2]==0 || t[$2]>$NF{t[$2]=$NF}
  END{for(r in t)printf("%8.2f ms to %-s\n",t[r]*1000,r)}
 '| sort -n
Enter fullscreen mode Exit fullscreen mode

Here are the results from home (I live near Lausanne in Switzerland):

   91.36 ms to
   96.03 ms to
  110.03 ms to
  110.66 ms to
  120.62 ms to
  121.05 ms to
  123.72 ms to
  173.18 ms to
  182.34 ms to
  188.49 ms to
  193.64 ms to
  199.27 ms to
  227.94 ms to
  260.93 ms to
  266.01 ms to
  269.80 ms to
  273.51 ms to
  286.98 ms to
  288.28 ms to
  291.29 ms to
  291.33 ms to
  298.87 ms to
  311.29 ms to
  333.56 ms to
  334.21 ms to
  358.49 ms to

Enter fullscreen mode Exit fullscreen mode

This is interesting. The faster connect to the new region in Zurich in eu-central-2 is 110.03 milliseconds, slower than Frankfurt in Germany (eu-central-1) which is 91.36 milliseconds.

Tracing the route though internet

Let's traceroute to understand it better:

Franck:~ $ tracert

  1     1 ms     1 ms     1 ms  INTEL_CE_LINUX []
  2    12 ms    19 ms     9 ms []
  3    13 ms    10 ms    12 ms []
  4    18 ms    17 ms    16 ms []
  5     9 ms    12 ms    10 ms []
  6    12 ms    15 ms    12 ms
  7    22 ms    30 ms    23 ms
  8    35 ms    23 ms    28 ms []
  9     *        *        *     Request timed out.
 10     *        *        *     Request timed out.
 11     *        *        *     Request timed out.
 12     *        *        *     Request timed out.
 13     *        *        *     Request timed out.
 14     *        *        *     Request timed out.
 15     *        *        *     Request timed out.
 16    45 ms    31 ms    27 ms
Enter fullscreen mode Exit fullscreen mode

I traced all location Latitude/Longitude from

  • is my cable provider (SEFA) 
"ip": "",
"hostname": "",
"city": "Etoy",
"region": "Vaud",
"country": "CH",
"loc": "46.4859,6.4182",
"org": "AS31124 Societe Electrique des Forces de l'Aubonne",
"postal": "1163",
"timezone": "Europe/Zurich"
  • is the internet provider (Netplus), in Zurich: 
"ip": "",
"city": "Zürich",
"region": "Zurich",
"country": "CH",
"loc": "47.3667,8.5500",
"org": "AS15547 SA",
"postal": "8000",
"timezone": "Europe/Zurich"
  • is a German internet exchange point (DE-CIX), apparently the connection to Amazon, and this is Frankfurt 
"ip": "",
"hostname": "",
"city": "Frankfurt am Main",
"region": "Hesse",
"country": "DE",
"loc": "50.1155,8.6842",
"postal": "60306",
"timezone": "Europe/Berlin"
  • is my final destination, Amazon in Zurich 
"ip": "",
"city": "Zürich",
"region": "Zurich",
"country": "CH",
"loc": "47.3667,8.5500",
"org": "AS16509, Inc.",
"postal": "8000",
"timezone": "Europe/Zurich"

In the above route, the connection goes out of my internet provider network in Zurich, enter the Amazon network in Frankfurt and come back to Zurich. This is not very optimal but that's how internet works.

Hybrid Cloud

I've run the same from an OCI (The Oracle Cloud) machine in Zurich:
Even from another cloud also in Zurich (and it could even happen that they share the same data centers, I know that Oracle Cloud is hosted in Equinix, but AWS do not disclose it) it is faster to connect to another region.

Here is the result of my script to get the fastest of 10 connections to each AWS region:

Encryption and Direct Connect

The conclusion: in the cloud, do not guess anything when going through the internet. If you want to keep your data in your country, be sure that the network is encrypted (example for YugabyteDB: Encryption in transit) and to have predictable performance, use dedicated network (like AWS Direct Connect) . Without it, connecting to a region in the same country is not a guarantee of staying there or taking the shortest route.

Top comments (1)

napicella profile image
Nicola Apicella

Nice write up 👏