elastic beanstalk、java spring boot和rds multi-az部署

toe95027  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(428)

我们将在运行Java8(而不是Corretto8)的ElasticBeanstalk上部署SpringBoot2.3应用程序。
我们正在考虑对rds使用multi-az,我正在阅读自述文件https://docs.aws.amazon.com/amazonrds/latest/userguide/concepts.multiaz.html
其中有一部分指出,在发生故障转移时,我们应该注意dns缓存 Setting the JVM TTL for DNS name lookups 上面写着

The default TTL can vary according to the version of your JVM and whether a
 security manager is installed. 
Many JVMs provide a default TTL less than 60 seconds. 
If you're using such a JVM and not using a security manager, 
you can ignore the rest of this topic. For more information on security managers 
in Oracle, see The security manager in the Oracle documentation.

在elastic beanstalk中Java8的默认值是什么?我好像找不到。
根据我的理解,如果ttl值很大,并且数据库发生故障,它不会故障转移到另一个az中的示例,因为dns不会改变。对吗?
还有就是默认值太大,spring引导的方式是什么,不使用xml文件就设置这个属性?
提前多谢了

u4vypkhs

u4vypkhs1#

您可以使用如下代码在jvm中对此进行调优:

java.security.Security.setProperty("networkaddress.cache.ttl" , "1");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "1");

此值是缓存数据的秒数。
但是,您可能还需要考虑rds代理,因为它可以加快故障切换。应该没有代码更改,只有配置更改。rds代理没有额外费用。

相关问题