User guide

Many resources available to help with configuring TCP buffer sizes and operating system specific TCP
settings, including:
TCP Tuning and Network Troubleshooting
Host Tuning
Setting the JVM TTL for DNS Name Lookups
For Java applications that access Amazon Web Services (AWS), we recommend that you configure your
Java virtual machine (JVM) with a time-to-live (TTL) of 60 seconds for DNS name lookups.
The JVM caches DNS name lookups.That is, when the JVM resolves a DNS name to an IP address, it
caches the IP address for a period of time. During this time period, the JVM uses the cached IP address
rather than querying a DNS server. This time period is known as the time-to-live or TTL. The default TTL
varies with the version of the JVM and also depends on whether a security manager is installed.
In some cases, the JVM default TTL is set to never re-resolve DNS names to IP addresses. This means
that when the IP address for an AWS resource changes, the application will be unable to connect to that
resource until someone manually restarts the JVM so that the new IP addresses can be picked up. In
these cases, it is vital that the TTL be configured to a shorter time period.
A TTL of 60 seconds ensures that if there is a change in the IP address that corresponds to an AWS
resource, the JVM will refresh the cached IP value after a relatively brief period of time. If the TTL value
is too large, Java applications may fail to connect to AWS resources because the cached IP has become
invalid.
You can configure the TTL in the file java.security, which is located in the directory %JRE%\lib\security.
The configured value specifies the number of seconds that the JVM should cache a successful DNS
name lookup. Here is an example that shows how to configure the TTL to 60 seconds.
networkaddress.cache.ttl=60
You can also configure the TTL programmatically using the following code
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
Note that the JVM is a shared resource; multiple Java applications could be using the same JVM.The
TTL value affects all Java applications that use the JVM.
Exception Handling
Understanding how and when the AWS SDK for Java throws exceptions is important in order to build
high-quality applications using the SDK.The following sections describe the different cases of exceptions
that are thrown by the SDK and how to handle them appropriately.
Why Unchecked Exceptions?
The AWS Java SDK uses runtime (or unchecked) exceptions instead of checked exceptions for a few
reasons:
Version v1.0.0
13
AWS SDK for Java Developer Guide
Setting the JVM TTL for DNS Name Lookups