最小化 DNS 查找?
我正在努力提高我的网站的性能。如果将图片、样式等静态资源的域名替换为对应的IP地址,性能是否会得到提升?如果是这样,这种方法有什么缺点吗?
I'm trying to improve the performance of my site. If I replace the domain names of static resources such as images, styles, etc. with corresponding IP address, would I gain performance improvement? If so, are there any down sides to this approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您会在首次 DNS 查找性能方面获得小幅改进,但会失去 DNS 提供的灵活性:更改主机 IP,而无需更改对主机的所有静态引用、基于 DNS 的负载平衡等。设计良好的 CDN策略将为您提供更好的服务。努力平衡并发请求与 DNS 查找,具体取决于每页静态资源的数量,介于 2 到 4 个 DNS 主机名之间。
You'd gain a small improvement in first time DNS lookup performance but you lose the flexibility that DNS provides: change a host IP without having to change all of the static references to the host, DNS based load balancing, etc. A well designed CDN strategy will serve you much better. Work on balancing concurrent request vs DNS lookups, depending on the number of static resources per page, that'll be between two and four DNS hostnames.
如果您发现 DNS 给现场实际用户造成了真正的延迟,您应该更改您的 DNS 提供商。
您的权威 DNS 提供商至少应该使用选播来服务来自与最终用户相同大陆的请求。
甚至不要考虑在内部运行权威 DNS。每次都将其外包(注意:为您的基础设施运行您自己的解析器,如果有意义的话;用户的浏览器不会使用这些解析器)。
If you find that DNS is causing real delays for actual users in the field, you should change your DNS provider.
Your authoritative DNS provider should at least be using anycast to serve the requests from the same contintent as the end-user.
Don't even think about running authoritative DNS in-house. Outsource it every time (NB: Run your own resolvers for your infrastructure, if that makes sense; users' browsers won't be using those).