提问 HN:生产应用中使用 /etc/hosts 而非 DNS 的看法?
4 分•作者: notepad0x90•8 个月前
HN,大家好,
“永远是 DNS 的问题”是我们遇到服务中断时都熟悉的一个说法。我理解为什么 DNS 对大多数用户来说至关重要。但是,对于使用“基础设施即代码”系统管理/部署的应用程序,变更可以并且应该以与代码变更相同的方式(DevOps 等)进行推送,那么在所有地方都使用 /etc/hosts 文件有任何坏处吗?
这样,名称到 IP 地址的关联变更就可以从 IaC 中受益,并且可以最大限度地减少与 DNS 相关的稳定性问题。当然,我假设名称到 IP 地址的关联首先是由系统工程师控制的,对于所有其他用例,仍然可以使用并且应该使用 DNS。
为什么云服务提供商和 FAANG 公司还没有这样做呢?在这些公司里,通过消除 DNS 请求流量和 CPU 周期等来节省成本是受到鼓励的。
查看原文
Hi HN,<p>"It's always DNS" is a theme we're all familiar with when it comes to outages.
I understand why DNS is critical for most users. But for applications that are managed/deployed using an "Infrastructure as Code" system, where changes can, and should always be pushed in a way that treats the changes the same way code changes are treated (Devops and all that), is there any harm with using /etc/hosts files everywhere?<p>That way name-to-ip association changes benefit from IaC, and DNS related instabilities are minimized. Of course, I am assuming the name-to-ip association is under the control of the system's engineers to begin with, for every other use case DNS can and should still be used.<p>Why aren't cloud providers and FAANGs doing this already, where saving costs by eliminating things like DNS request traffic and CPU cycles is encouraged?