关于微服务的二三事

最近,由于一些原因在疯狂的恶补关于微服务架构的一些东西,虽然有很多东西还是不太清楚,不过对于微服务的核心和相关价值也算是有了一定的了解,现在将一些有趣的点记录下来,供给希望了解微服务的同学做一些参考。

聊到微服务,我们第一个需要讲到的是SOA,之前我也写过一片关于单体架构和SOA的一些东西,有兴趣的同学可以去这里找找看。Link

简单来说,微服务是一个架构的概念,它的核心思路是拆分,通过把完整项目做微服务化来实现松耦合的目标。比较典型的演进方向如下

 

 

微服务不再强调传统SOA架构里面比较重的ESB企业服务总线,真正地实现服务自治。而将SOA的思想进入到单个业务系统内部,实现真正的组件化。

当然把一个application拆分成一些更小的模组块是需要进行业务改造的,而且越成熟的企业业务改造的内容也会越复杂。但是这些改造对于企业架构来说是必要的,微服务可以极大的提升整体系统的稳定性,实现服务自治,而且可以按业务组织团队,将整体架构模型收缩到最小,也可以让每块组件的复用率更高。打个最简单的例子,比如一个电商秒杀活动,以前单体架构的感受是:高峰期人多的时候,页面刷不开,等刷开的时候,东西都被都抢光了。给人体验非常不好。为了提高体验,对单体架构进行扩容提升性能,只能购买昂贵的服务器,去支撑峰值流量,而绝大部分人都是在访问页面,后面的选择、(加入购物车)、下单、支付、每个环节的转换率都会使访问量降低,而单体架构的扩容是对所有功能进行整体扩容,造成大量浪费,如果采用微服务架构以后,可以针对浏览界面的服务做更多扩容,订单服务少量扩容,不再需要对所有功能进行整体扩容,所以把功能拆分微服务后,既能提升用户体验,又能实现节约硬件成本的作用。当然由于采用微服务,他的访问页面,下单,支付模块都是独立的,比如我现在要做另一个项目需要支付模块,其实完全可以复用。

去中心化的自治和去中心化的数据管理也可以让各个组件能针对不同的业务特点选择不同的技术平台。

那么我们来总结下刚刚所说的几点,首先微服务其实是对原有的单体架构,SOA架构做了进一步的拆分,让SOA的概念融入到每个企业组件,来实现松耦合,服务自治,动态扩容,节约成本的目的,最小颗粒度的概念也可以让组件的复用率更高。但是与之带来的是复杂的服务治理,服务调用,与去中心化带来的服务数据同步,异常排障困难等等等问题,也是微服务不得不面对的。我觉得这些问题的解决,应该就是腾讯云TSF平台最关键的价值把。

下面,我们脚踏实地来看看现有的微服务生态把:

1.Spring Cloud微服务架构

Spring Cloud是基于Spring Boot的微服务的框架,只能采用Java语言。
Spring Cloud是一个包含很多子项目的整体方案,其中由Netflix开发又并入的Spring Cloud Netflix 是Spring Cloud微服务架构的核心项目。

2.ZeroC IceGrid微服务架构

ZeroC IceGrid是基于RPC框架发展而来的一种微服务架构,具有良好的性能与分布式能力。

3.基于消息队列的微服务架构

除了基于RPC通信(包括类RPC的通信如Http Rest、SOAP等)的微服务架构,还有基于消息队列通信的微服务架构,这种架构下的微服务采用发送消息(Publish Message)与监听消息(Subscribe Message)的方式来实现彼此之间的交互。

目前比较流行的应该就是Spring boot + Spring Cloud的这一套微服务解决方案了。如果学过Java的同学,对于这一套应该不是很陌生。那我们下面就来讲讲Springcloud。

Spring Cloud是基于Spring Boot实现微服务的框架,包含多个子项目的整体方案包括配置管理、服务发现、断路器、路由、微代理、事件总线、全局锁、决策竞选、分布式会话等。

Spring boot 是 Spring 的一套快速配置脚手架,可以基于spring boot 快速开发单个微服务; Spring Cloud是一个基于Spring Boot实现的云应用开发工具。

所以Spring boot其实是springcloud的前提。

这时,有的小伙伴可能就会问了,那么springcloud的组件是怎样的啊?别着急,我们先来看看它的大体架构把:

 

 

组件

用途

Eureka

服务注册中心

Ribbon

客户端负载均衡,特性有区域亲和、重试机制

Feign

声明式服务调用,本质上就是Ribbon+Hystrix

Hystrix

客户端容错保护,特性有服务降级、服务熔断、请求缓存、请求合并、依赖隔离。

Config

分布式配置中心,支持本地仓库、SVN、Git、Jar包内配置等模式

Zuul

API服务网关,功能有路由分发和过滤

Bus

消息总线

Netflix 公司提供了包括Eureka、Hystrix、Zuul、 Archaius等在内的很多组件,在微服务架构中至关重要,Spring在Netflix 的基础上,封装了一 系列的组件,命名为:Spring Cloud Eureka、Spring Cloud Hystrix、Spring Cloud Zuul等。 更多介绍

介绍完Springcloud,我们来看看什么是服务网格(Service Mesh)

 

 

根据Linkerd CEO William Morgan定义,Service Mesh是用于处理服务间通信的基础设施层,用于在云原生应用复杂的服务拓扑中实现可靠的请求传递。在实践中,Service Mesh通常是一组与应用一起部署,但对应用透明的轻量级网络代理。

Service Mesh 通常是由一系列轻量级的网络代理组成的,如上图中的蓝色块就是网络代理(这个网络代理也被称之为Sidecar),深绿色块就是我们的应用。各个微服务应用之间的通信都被网络 代理劫持,相当于在服务之间加了一个中间层,应用之间要想通信,必须要通过这个中间层;这 个网络代理与应用程序部署在一起,但是相对于应用程序来说它是完全不需要知道有这个网络代 理的。

Sidecar模式是一种将应用功能从应用本身剥离出来作为单独进程的方式。该模式允许我们应用无侵入添加多种功能,避免了为满足第三方组件需求而向应用添加额外的配置代码。

总的来说Service Mesh主要解决的是SpringCloud对异构语言兼容,让开发者可以无需重构去兼容一些非SpringBoot的一些语言。

典型的场景如下:

 

这些,应该就是微服务的基础了,当然除了SpringCloud,我们还有很多基于RPC的框架,比如腾讯的TARS,更多的内容我总结了一个xmind,感兴趣的同学可以研究下:

 

本人水平有限,如有错误,还请各位大佬指正  -v-



719 thoughts on “关于微服务的二三事”

  • I think this is one of the most important info for me. And i’m glad reading your article. But should remark on some general things, The website style is perfect, the articles is really great : D. Good job, cheers

  • This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  • Thanks for your tips on this blog. One particular thing I would wish to say is purchasing electronics items in the Internet is certainly not new. In reality, in the past few years alone, the market for online electronic devices has grown drastically. Today, you can get practically just about any electronic gadget and product on the Internet, ranging from cameras and also camcorders to computer spare parts and video games consoles.

  • I am really impressed together with your writing skills as smartly as with the layout in your weblog. Is this a paid subject matter or did you modify it yourself? Either way keep up the nice high quality writing, it?s uncommon to see a great weblog like this one these days..

  • The very core of your writing while appearing agreeable in the beginning, did not really work well with me after some time. Somewhere throughout the sentences you were able to make me a believer unfortunately just for a while. I still have got a problem with your jumps in assumptions and you might do well to help fill in those breaks. When you actually can accomplish that, I will definitely be fascinated.

  • I?m not positive where you are getting your info, but good topic. I must spend some time finding out more or understanding more. Thank you for wonderful information I was in search of this information for my mission.

  • Things i have continually told individuals is that when looking for a good online electronics store, there are a few elements that you have to take into consideration. First and foremost, you want to make sure to look for a reputable plus reliable retailer that has received great testimonials and ratings from other shoppers and market sector leaders. This will make certain you are dealing with a well-known store that can offer good program and aid to the patrons. Many thanks sharing your thinking on this site.

  • Thanks a lot for the helpful content. It is also my belief that mesothelioma has an really long latency period, which means that warning signs of the disease might not emerge until 30 to 50 years after the preliminary exposure to asbestos fiber. Pleural mesothelioma, that is the most common type and influences the area throughout the lungs, could cause shortness of breath, torso pains, and also a persistent coughing, which may bring about coughing up our blood.

  • certainly like your web site but you have to check the spelling on several of your posts. Several of them are rife with spelling problems and I find it very bothersome to tell the truth nevertheless I?ll surely come back again.

  • Hello There. I discovered your weblog using msn. This is a really neatly written article. I?ll be sure to bookmark it and return to learn extra of your useful information. Thank you for the post. I?ll certainly comeback.

  • I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get got an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case you shield this hike.

  • This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

  • Appreciate you for sharing these kind of wonderful content. In addition, the ideal travel and also medical insurance approach can often eradicate those worries that come with travelling abroad. Some sort of medical crisis can rapidly become expensive and that’s bound to quickly place a financial load on the family finances. Putting in place the great travel insurance offer prior to setting off is worth the time and effort. Cheers

  • An impressive share! I have just forwarded this onto a colleague who had been doing a little homework on this. And he in fact bought me dinner because I found it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanx for spending time to talk about this subject here on your site.

  • I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.

  • Thanks for expressing your ideas with this blog. Additionally, a fairy tale regarding the banking companies intentions if talking about property foreclosure is that the lender will not getreceive my installments. There is a fair bit of time which the bank can take payments every now and then. If you are as well deep in the hole, they’ll commonly desire that you pay the payment in full. However, that doesn’t mean that they will not take any sort of repayments at all. In the event you and the loan company can have the ability to work a little something out, the foreclosure course of action may cease. However, when you continue to miss out on payments in the new strategy, the home foreclosure process can pick up where it was left off.

  • Hi my family member! I wish to say that this post is awesome, great written and include almost all significant infos. I would like to look more posts like this .

  • Whats up very cool website!! Guy .. Beautiful .. Superb .. I will bookmark your web site and take the feeds additionally?I’m glad to seek out so many helpful information here in the put up, we want work out extra techniques on this regard, thank you for sharing. . . . . .

  • Thanks for the diverse tips contributed on this website. I have realized that many insurance carriers offer consumers generous savings if they elect to insure multiple cars together. A significant number of households own several autos these days, especially those with mature teenage children still dwelling at home, and the savings for policies may soon increase. So it pays to look for a great deal.

  • There are certainly quite a lot of details like that to take into consideration. That is a nice level to bring up. I offer the thoughts above as basic inspiration but clearly there are questions like the one you carry up where the most important factor will likely be working in trustworthy good faith. I don?t know if finest practices have emerged around issues like that, however I am positive that your job is clearly identified as a good game. Each girls and boys feel the impression of only a second?s pleasure, for the rest of their lives.

  • Hello There. I found your blog the usage of msn. That is a really smartly written article. I?ll make sure to bookmark it and return to learn extra of your useful information. Thanks for the post. I will definitely comeback.

  • Another thing is that when you are evaluating a good on-line electronics store, look for online shops that are regularly updated, retaining up-to-date with the most recent products, the best deals, and helpful information on services. This will make certain you are doing business with a shop which stays atop the competition and provide you what you need to make educated, well-informed electronics buys. Thanks for the important tips I have learned from the blog.

  • I’m really impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you modify it yourself? Anyway keep up the excellent quality writing, it is rare to see a great blog like this one today..

  • It is perfect time to make some plans for the longer term and it’s time to be happy. I have learn this publish and if I may I wish to counsel you some fascinating issues or suggestions. Maybe you can write next articles regarding this article. I desire to read more things approximately it!

  • I will also like to say that most people that find themselves with out health insurance are generally students, self-employed and those that are out of work. More than half in the uninsured are really under the age of 35. They do not experience they are requiring health insurance simply because they’re young in addition to healthy. Their own income is usually spent on property, food, as well as entertainment. Most people that do work either complete or not professional are not given insurance by their work so they get along without owing to the rising expense of health insurance in the country. Thanks for the tips you reveal through this website.

  • Based on my observation, after a the foreclosure home is marketed at a bidding, it is common for your borrower to be able to still have a remaining balance on the financial loan. There are many lenders who try to have all costs and liens paid off by the subsequent buyer. Even so, depending on specific programs, legislation, and state guidelines there may be many loans that are not easily resolved through the shift of financial loans. Therefore, the obligation still lies on the consumer that has obtained his or her property in foreclosure. Many thanks sharing your thinking on this blog.

  • Hi my loved one! I want to say that this article is amazing, great written and include almost all vital infos. I?d like to see extra posts like this .

  • I’m impressed, I have to admit. Seldom do I come across a blog that’s both educative and entertaining, and let me tell you, you have hit the nail on the head. The issue is something that too few men and women are speaking intelligently about. Now i’m very happy I came across this during my search for something concerning this.

  • I’m amazed, I must say. Seldom do I come across a blog that’s equally educative and entertaining, and let me tell you, you’ve hit the nail on the head. The problem is something that not enough people are speaking intelligently about. Now i’m very happy that I found this in my hunt for something concerning this.

  • I?ve been exploring for a bit for any high-quality articles or blog posts on this sort of space . Exploring in Yahoo I finally stumbled upon this website. Reading this info So i?m glad to exhibit that I have a very just right uncanny feeling I came upon exactly what I needed. I so much unquestionably will make sure to do not forget this website and provides it a look on a continuing basis.

  • Thanks for the various tips contributed on this website. I have seen that many insurance agencies offer shoppers generous special discounts if they opt to insure a few cars with them. A significant volume of households own several cars these days, particularly those with elderly teenage children still dwelling at home, and the savings with policies can soon begin. So it pays to look for a bargain.

  • you’re really a good webmaster. The website loading speed is amazing. It seems that you are doing any unique trick. In addition, The contents are masterwork. you have done a fantastic job on this topic!

  • Thanks for your strategies. One thing I’ve noticed is that banks plus financial institutions have in mind the spending routines of consumers while also understand that most people max out there their own credit cards around the holidays. They wisely take advantage of that fact and start flooding your current inbox as well as snail-mail box along with hundreds of Zero APR card offers shortly after the holiday season comes to an end. Knowing that in case you are like 98 in the American community, you’ll soar at the opportunity to consolidate personal credit card debt and switch balances for 0 annual percentage rates credit cards.

  • hello there and thank you on your information ? I?ve certainly picked up something new from right here. I did on the other hand experience several technical points the usage of this website, as I skilled to reload the web site many instances previous to I may get it to load correctly. I were brooding about if your web hosting is OK? Not that I am complaining, however sluggish loading cases instances will sometimes impact your placement in google and can injury your quality score if ads and ***********|advertising|advertising|advertising and *********** with Adwords. Anyway I am adding this RSS to my e-mail and can glance out for a lot more of your respective exciting content. Make sure you update this once more very soon..

  • I just could not depart your website before suggesting that I actually enjoyed the standard info a person provide for your visitors? Is going to be back often in order to check up on new posts

  • Simply wish to say your article is as astonishing. The clarity on your post is simply great and that i could think you’re knowledgeable in this subject. Well with your permission allow me to grab your RSS feed to stay up to date with approaching post. Thanks a million and please carry on the rewarding work.

  • Hi, i believe that i noticed you visited my site thus i came to ?go back the desire?.I’m attempting to to find issues to improve my web site!I assume its adequate to make use of some of your ideas!!

  • I do accept as true with all the ideas you’ve introduced for your post. They’re very convincing and can certainly work. Still, the posts are very quick for novices. Could you please extend them a bit from subsequent time? Thank you for the post.

发表评论

邮箱地址不会被公开。 必填项已用*标注

15 ÷ 3 =