User guide
TCP Socket Buffer Size Hints
Advanced users who want to tune low-level TCP parameters can additionally set TCP buffer size hints
through the ClientConfiguration object.The majority of users will never need to tweak these values,
but they are provided for advanced users.
Optimal TCP buffer sizes for an application are highly dependent on network and OS configuration and
capabilities. For example, most modern operating systems provide auto-tuning logic for TCP buffer sizes,
which can have a big impact on performance for TCP connections that are held open long enough for
the auto-tuning to optimize buffer sizes.
Large buffer sizes (e.g., 2 MB) allow the OS to buffer more data in memory without requiring the remote
server to acknowledge receipt of that information, so can be particularly useful when the network has
high latency.
This is only a hint, and the OS may choose not to honor it. When using this option, users should always
check the operating system's configured limits and defaults. Most OS's have a maximum TCP buffer size
limit configured, and won't let you go beyond that limit unless you explicitly raise the max TCP buffer size
limit.
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
Version v1.0.0
16
AWS SDK for Java Developer Guide
TCP Socket Buffer Size Hints