正如敏捷之父MartinFowler所说的那样,单体架构和微服务并不是简单的二选一,两者都是模糊的定义,这就意味着大多数系统都将在一个模糊的边界区域。很多开发团队已经认识到微服务架构比单体架构更优越,但是也有其他团队感觉到这是一种消弱生产力的负担,就像任何软件架构,微服务架构同样有利弊。为了能做出一个明智的选择,你必须了解这些应用并将它们运用到你特定的环境中。
微服务的“定义”
如果需要准确的给微服务下一个定义,抱歉,笔者找了很长时间,也没有一个准确的定义,最接近微服务的定义来自维基百科,全文如下:
In computing, microservices is a softwarearchitecture style in which complex applications are composedof small, independent processes communicating witheach other using language-agnostic APIs.These services are small,highlydecoupled and focus ondoing a small task, facilitatinga modular approach to system-building.
敏捷之父Martin Fowler的《Microservices》一文中给出的定义是这样的:
In short, the microservice architectural style is an approach todeveloping a single application as a suite of small services, each running inits own process and communicating with lightweight mechanisms, often an HTTPresource API. These services are built around business capabilities andindependently deployable by fully automated deployment machinery. There is abare minimum of centralized management of these services, which may be writtenin different programming languages and use different data storage technologies.
综上,概括来说, 微服务架构风格是一种使用一套小服务来开发单个应用的方式途径,每个服务运行在自己的进程中,通过轻量的通讯机制联系,经常是基于HTTP资源API,这些服务基于业务能力构建,能够通过自动化部署方式独立部署,这些服务自己有一些小型集中化管理,可以是使用不同的编程语言编写,正如不同的数据存储技术一样。