面试的时候被问到微服务的边界的问题,一时不知怎么回答。
之后找到这篇文章,https://docs.microsoft.com/en-us/azure/architecture/microservices/model/microservice-boundaries

  • Each service has a single responsibility.
    说是从domain的角度考虑,这个有点抽象,还是从单一职责角度容易理解。

  • There are no chatty calls between services. If splitting functionality into two services causes them to be overly chatty, it may be a symptom that these functions belong in the same service.
    如果两个微服务之间有太多的对话,那么这两个就应该成为一个。

  • Each service is small enough that it can be built by a small team working independently.
    微服务开发不要跨开发组。

  • There are no inter-dependencies that will require two or more services to be deployed in lock-step. It should always be possible to deploy a service without redeploying any other services.
    Services are not tightly coupled, and can evolve independently.
    微服务之间不应该有依赖,应该能独立发展。

  • Your service boundaries will not create problems with data consistency or integrity. Sometimes it's important to maintain data consistency by putting functionality into a single microservice. That said, consider whether you really need strong consistency. There are strategies for addressing eventual consistency in a distributed system, and the benefits of decomposing services often outweigh the challenges of managing eventual consistency.
    从数据一致性上考虑,微服务不能把这个搞的复杂。

多面试有好处,比光啃书经验长的快多了。