关注「前端向后」微信公众号,你将收获一系列「用心原创」的高质量技术文章,主题包括但不限于前端、Node.js以及服务端技术
本文首发于 ayqy.net ,原文链接:http://www.ayqy.net/blog/微服务架构(microservices)/
零.从 Monolithic application 说起
Monolith means composed all in one piece. The Monolithic application describes a single-tiered software application in which different components combined into a single program from a single platform.
(摘自Introduction to Monolithic Architecture and MicroServices Architecture)
把软件应用的不同组件都放到一个程序中,就叫 Monolithic application。例如,通过编程语言的基本特性将应用划分成类、函数和命名空间,用部署流水线来保证变更都经过测试后才部署到生产环境,并通过负载均衡机制运行多个实例,将其进行横向扩展:
All your logic for handling a request runs in a single process, allowing you to use the basic features of your language to divide up the application into classes, functions, and namespaces. With some care, you can run and test the application on a developer’s laptop, and use a deployment pipeline to ensure that changes are properly tested and deployed into production. You can horizontally scale the monolith by running many instances behind a load-balancer.
在这种架构模式下,应用程序也能很好地工作,但存在 2 个问题:
-
变更受限制:很小的一处变更也需要对整个应用进行重新构建和部署,而且难以控制变更的影响范围
-
不利于扩展:无法仅扩展应用中需要更多资源的那些部分,只能扩展整个应用
这些限制在云环境下尤其突出。于是,微服务架构登上了舞台
一.微服务架构是什么?
Microservices are a software development technique—a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight.
(摘自Microservices)
面向服务架构(SOA)的一种变体,把应用程序设计成一系列松耦合的细粒度服务,并通过轻量级的通信协议组织起来
Building applications as suites of services. As well as the fact that services are independently deployable and scalable, each service also provides a firm module boundary, even allowing for different services to be written in different programming languages. They can also be managed by different teams.