Avoid JVM DNS Caching Problems in AWS

Certain older versions of JDK have forever caching by default. This poses a problem if you have a Java application that calls ELB/ALB or ElasticSearch Clusters. When any action is made to modify a setting in AWS ElasticSearchService or an update happens the cluster doubles in size, the shards are replicated to the new nodes and the old nodes are removed. Queue up the dramatic music and a Java application in trouble.

To avoid this issue simply set the java.security ttl as per the following AWS link: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-jvm-ttl.html

By setting $JAVA_HOME/jre/lib/security/java.security file to networkaddress.cache.ttl=60 your application will now play nice with ELB/ALB IP changes and ElasticSearch cluster node replacements.