'Any scenario where host-based routing is better than path-based routing
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
