默默学微服务:微服务概述


声明:本文转载自https://my.oschina.net/liululee/blog/3053287,转载目的在于传递更多信息,仅供学习交流之用。如有侵权行为,请联系我,我会及时删除。

1.什么是微服务

什么是微服务,一千个人有一千个哈姆雷特,wikepedia也有很多不同的讨论,维基上如是说道:


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. The benefit of decomposing an application into different smaller services is that it improves modularity. This makes the application easier to understand, develop, test, and become more resilient to architecture erosion. It parallelizes development by enabling small autonomous teams to develop, deploy and scale their respective services independently.It also allows the architecture of an individual service to emerge through continuous refactoring.[3] Microservices-based architectures enable continuous delivery and deployment


简单翻译一下:微服务是一种软件开发技术,是面向SOA架构的变体,在微服务中,服务是细粒度的,协议是轻量级的。微服务架构提高了程序的模块性,使程序理解、开发、测试更加简单方便。它使小型自治团队能够独立地开发、部署和扩展各自的服务,从而并行化开发。它还允许通过持续重构形成单个服务的体系结构。基于微服务的体系结构支持连续交付和部署。 在Martin Flower的博客中,微服务的描述如下:


In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies


微服务架构风格是一种用来将单体应用开发为多个小型服务的方法,并且这些服务之间都通过轻量级的通信机制通信,比如:HTTP资源API。 这些服务围绕业务能力构建并能全自动独立部署。这些服务共用一个小型的集中式管理服务,可以使用不同语言开发,不同数据存储技术。

简单归纳下:微服务—— 一系列的细粒度轻量级通信机制独立运行全自动部署的服务。

2.微服务的正反面

微服务的优点很显而易见:开发、测试更加快,项目迭代也可以很迅速,而且使用的技术不受限制,为开发工作带来很大的灵活性,而且某个微服务在遇到性能瓶颈时,能够通过提升硬件配置迅速扩容,提高负载能力。 这么一看,感觉微服务好叼噢,似乎完美地没有缺点,然而,仔细想想 1.单体架构,只需要保证一个应用的正常运行,而微服务需要保证几十几百个甚至更多的服务能正常运行。 2.微服务天生就是分布式的架构,对于系统的容错性,网络延迟,以及分布式事务都将会带来巨大挑战。 3.接口调整成本高,若某个接口被多个微服务调用,当这个接口发生改变,其他所有调用者都要改变,因此在设计接口时,要考虑兼容性。 4.重复劳动,多个微服务使用相同的功能。

3.如何实现微服务架构

目前微服务的技术栈也很多,技术选型也有很多的选择,在本系列教程中,我会尽量覆盖多的组件。 当然大部分都是建立在Spring Cloud之上(当然也可以选择Apache Dubbo) 微服务架构大致可以分为: 1.服务注册与发现 2.服务路由与负载均衡 3.容错处理 4.服务网关 5.配置中心 6.消息队列 7.链路追踪 然后微服务还涉及一些领域驱动设计(Domain Driven Design,简称DDD)相关的知识,当然这些都是后话。一个系统的复杂度是由两个因素决定的:业务复杂度和技术复杂度。

业务复杂度:系统设计层面讲,如何能让微服务更好的工作,系统设计更加合理,业务分层更加清晰,这些DDD可以给我们提供一些指导意见。 技术复杂度:微服务虽然好,但是带来的开发和技术挑战也是一样很高的。

整体架构图如下:(图片来源谷歌搜索,侵权请联系删除)

4.资料

维基百科:https://en.wikipedia.org/wiki/Microservices#Introduction

Martin Flower 博客: https://martinfowler.com/articles/microservices.html

本文发表于2019年05月23日 18:00
(c)注:本文转载自https://my.oschina.net/liululee/blog/3053287,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除.

阅读 1929 讨论 0 喜欢 0

抢先体验

扫码体验
趣味小程序
文字表情生成器

闪念胶囊

你要过得好哇,这样我才能恨你啊,你要是过得不好,我都不知道该恨你还是拥抱你啊。

直抵黄龙府,与诸君痛饮尔。

那时陪伴我的人啊,你们如今在何方。

不出意外的话,我们再也不会见了,祝你前程似锦。

这世界真好,吃野东西也要留出这条命来看看

快捷链接
网站地图
提交友链
Copyright © 2016 - 2021 Cion.
All Rights Reserved.
京ICP备2021004668号-1