基于主机的路由比基于路径的路由更好的任何场景

发布于 2025-01-29 19:58:05 字数 748 浏览 3 评论 0原文

事实

在第7层负载平衡器上,我们可以进行两种路由:

  • 基于主机的路由:a.example.com转到上游1,而B.Example.com访问
  • 基于上游B路径的路由:example.com/a进入上游1,而example.com/b进入上游2

我的感知

基于路径的路由比基于主机的路由更好,因为:

  • 维护基础架构的努力较少:使用主机 - 基于路由,每个新服务都以新域名公开,因此需要DNS记录才能解决该新域名到同一lb。 DNS记录是“下属”的事情。如果系统拥有50多个服务,则所有DNS记录的供应/管理将不会很琐碎。当有多种环境(例如DEV,测试,分期和生产)时,每个新服务将需要一个以上的域名(以及DNS记录),这使其更难管理。
  • 无需关心CORS。
  • 客户不必为HostNames提供名牌名称:有时,客户对他们可以访问的域名有非常严格的规则,并且可能需要6个月到一年的时间才能要求他们许可以将域名白名单。基于路径的路由意味着新服务也位于旧域之下,因此客户不必再次打扰。

问题

是否有任何场景,基于主机的路由比基于路径的路由更好?我希望开发人员和运营商的意见。特定的例子非常欢迎!

PS:这个问题是在提出意见,因此可能不是典型的意见。但是,我不确定哪种堆栈对此会更好,因为开发人员和运营商都聚集在一起,我想听听双方的想法。请让我知道另一个网站是否更适合这种问题。

Fact

On Layer 7 Load Balancers, we can do 2 kinds of routing:

  • Host-based routing: a.example.com goes to upstream 1 while b.example.com goes to upstream b
  • Path-based routing: example.com/a goes to upstream 1 while example.com/b goes to upstream 2

My Perception

Path-based routing is better than host-based routing because:

  • Less effort to maintain infrastructure: with host-based routing, each new service is exposed under a new domain name and therefore a DNS record is required to resolve that new domain name to the same LB. DNS record is an "infra" thing. If the system has 50+ services then provisioning/managing all the DNS records won't be trivial. When there are multiple environments like dev, test, staging and production, each new service will then require more than one domain name (and therefore DNS records) which makes it even harder to manage.
  • No need to care about CORS.
  • Customers don't have to whitelist as many hostnames: sometimes, customers have very strict rules around what domain names they can access and it may take 6 months to a year for them to ask for permission to whitelist a domain name. Path-based routing means new services are also under the old domain so customers don't have to bother with that again.

Question

Are there any scenarios where host-based routing is better than path-based routing? I would like opinions from both Devs and Operators. Specific examples are more than welcome!

PS: This question is asking for opinions so may not be what is typical on SO. However, I'm not sure which stack is better for this because SO is where both Devs and Operators gather and I would like to hear both sides' ideas. Please let me know if another site is more suitable for this kind of question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文