Honoring DNS TTLs

Describes how to ensure that your application does not lose access to Amazon SimpleDB as a result of incorrect TTL handling.


Submitted By: Bruce@AWS
AWS Products Used: Amazon SimpleDB
Created On: August 5, 2010 7:02 PM GMT
Last Updated: August 6, 2010 8:49 PM GMT

When you make requests to Amazon SimpleDB, you specify an endpoint based on the Region you are using. For example, if you store data in the US-West (Northern California) Region, you specify sdb.us-west-1.amazonaws.com.

The Domain Name System (DNS) associates all Internet domain names (including sdb.us-west-1.amazonaws.com*) with specific IP addresses. When a computer on the Internet looks up the IP address for a domain name, it also reads its time-to-live (TTL). The TTL is the amount of time the computer waits before checking whether the IP addresses for a domain name have changed.

To enable traffic to be rerouted to different IP addresses in the event of problems or configuration changes, we use short time-to-lives (TTLs). If your application does not honor the short TTLs, it might make requests to unavailable IP addresses that will prevent it from being able to access Amazon SimpleDB.

When using a Java version prior to 1.6, it caches DNS lookups indefinitely and might never find an updated address. Versions 1.6 and later do not cache lookups indefinitely, but they do not honor our TTLs. If you are using Java, fix this problem by doing one of the following:

  • Call 'java.security.Security.setProperty("networkaddress.cache.ttl" , "0");' in your code before the JVM sets up any network connections. For example, this will not work if you run your application inside of Tomcat.
  • Run the JVM with the following options: '-Dsun.net.inetaddr.ttl=0' . For example:
    java -Dsun.net.inetaddr.ttl=0 rest of your java startup options

Most other languages rely on your operating system's DNS cache, which correctly honors DNS TTLs. However, you should make sure that your local DNS servers are configured to use our TTLs. If they cache information for too long, you might have connectivity problems. If they do not cache it long enough, latency might be introduced while DNS is resolved.

©2017, Amazon Web Services, Inc. or its affiliates. All rights reserved.