Domain names vs URL path for web services

A team at the office is developing web micro-services intended to support sales sites and mobile apps with total combined orders count of less than 100K (not sure how much less but greater than 10K) per month.

They are using NodeJS, Docker and AWS. Their idea is that each service will only have one or two endpoints and its own DB.

For example there would be a Tax service that only GETs the tax calculated for an Order object, then another PlaceOrder service receives a POST with an Order object, possibly another CheckStatus service would return current status for an Order object or ID etc.

Each of these services is actually a completely separate NodeJS project, hosted in a separate repo, compiled by a separate Jenkins project and put in its own Docker container, which is then deployed on a server of its own (Beanstalk)

Each of these servers then gets a domain name for each of its deployment phases (DEV, QA, INT, STAGE, PROD), so for the two services we have in the example there are 10 domain names: PHASE.taxService.api.company.com
and PHASE.orderService.api.company.com

Question is: is this a normal practice, do you see benefits or issues with this scenario. Is there a reason to prefer either dev.taxService.api.company.com or dev.company.com/api/taxService?

4

Update: this is an old answer that implies HTTP/1.1. For HTTP/2 the logic is more or less the same except multiplexing, if supported by both ends, allows to have one TCP connection per host.


This is an interesting and important question, I’m surprised it hasn’t gotten much attention.

In addition to @thexacre’s response, you need to consider your client’s behavior and how it may choose to reuse connections. From the client’s perspective a host is a single entity that can serve requests to various paths within one HTTP connection (the Keep-alive feature). The keep-alive timeout can be e.g. one minute but it can be configured on the client side and negotiated with the server. The second factor is the client’s maximum number of simultaneous connections, also configurable but usually limited to save resources.

Having said that, you need to look at how often each of your endpoints will be called by the client and whether the client will benefit from HTTP connection reuse. The one host + multiple paths strategy seems to be more convenient from the client’s perspective, because it may choose to fire multiple requests simultaneously, or to serialize them depending on whether it wants to save local resources (memory and CPU) or to retrieve data as fast as possible.

On the other hand, if a client has to deal with many host names it means it will create separate HTTP connections with each one of them; connection reuse will be impossible.

Then there’s the server side. If you are running a microservice architecture it means for a one-host strategy you will need to have a request router, a potential bottleneck. It is more convenient from the server’s perspective to have separate host names for logically isolated endpoint groups: you will have a flexibility of choosing an architecture (microservice vs. monolithic), changing the architecture later, migration as mentioned in the other answer, potentially no need for a router, etc.

All in all, I would say if the client can potentially make a great number of requests within a limited amount of time, and if it is important to handle them efficiently on the client side then the client will benefit from fewer host names, ideally just one. However, if the client makes only a few requests at a time then consider what’s best for your service, and that would more likely be multiple host names.

2

Is there a reason to prefer either
dev.taxService.api.company.com or dev.company.com/api/taxService?

It seems basically your question boils down to whether it’s better to use sub-domains or sub-directories to separate services.

It seems there’s plenty of people on either side of the fence, for example:

Google seems to prefer sub-directories, here’s two examples of different services:

  • Gmail service: https://www.googleapis.com/upload/gmail/v1/users/userId/drafts
  • Analytics service: https://www.googleapis.com/analytics/v3/data/mcf

Amazon seems to prefer sub-domains, for example:

  • SQS: http://sqs.eu-west-1.amazonaws.com/
  • S3: http://s3-sa-east-1.amazonaws.com/

Personally I generally prefer sub-domains because:

  • They don’t require a load balancer / reverse proxy to map the sub-directory to a service.
  • Sub-directories make sense in the context of HTTP, but if your service involves other protocols then it may not.
  • It’s usually easier to split services between infrastructure providers using sub-domains which is useful during a migration. ie. you can easily move service 1 to provider B by pointing the sub-domain there, while service 2 remains on provider A. Doing that with a sub-directory will probably require you to reverse proxy to a totally separate data centre.

2

Your question is how should you separate your services: via DNS or via HTTP.

DNS

  • Does not require a shared load balancer. Traffic goes directly to that service’s infrastructure.

  • No complexity of path/subpath translations.

HTTP

  • Clients can re-use connections, improving latency especially for TLS (HTTPS).

  • Fewer DNS records and TLS certificates/names to manage.


For me, it’s a matter of how independent the services are.

Is this “one API”? Or “several APIs”?

To me, it sounds like your microservices are all part of the same logical API/application, even if you have implemented them as different processes. So in that particular case, I would separate phases by DNS and microservices by HTTP.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật