Skip to content
Advertisement

What’s the recommended way to set networkaddress.cache.ttl in Elastic Beanstalk?

I need to set Java’s DNS cache TTL (networkaddress.cache.ttl) for an Amazon Elastic Beanstalk app running in Tomcat 8. Because EB can start and stop server instances at any time, I can’t simply edit a Tomcat config file and the server and expect the change to persist.

I tried setting the networkaddress.cache.ttl and sun.net.inetaddr.ttl environment variables, but those had no effect. Amazon says calling java.security.Security.setProperty("networkaddress.cache.ttl" , "60"); “will not work if you run your application inside of Tomcat” (http://aws.amazon.com/articles/4035). What’s a good way to set the TTL?

Advertisement

Answer

The problem is that I was doing it wrong. Setting the sun.net.inetaddr.ttl environment variable works. You can do this in your Elastic Beakstalk config file:

JavaScript

60 seconds is the value recommended by Amazon

Another option that seems a little nicer to me is to create and use a java.security file:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement