EDA 事件驱动架构与 EventBridge 二三事

这篇文章很早之前就想写出来了,迫于对时间管理不到位一直被滞后。等真正要上前给人讲东西的时候才开始准备。这里就先当作一个记录吧。其实大部分人对去架构趋势,架构理解都是比较多的。这里也只是以EDA架构为引子,引出一些关于产品和技术趋势的思考。我们开始吧!

当下比较成功的企业已然认识到,要想最大限度提升运营效率和客户体验,务必将业务和技术两方面的举措紧密结合起来。运营事件或业务形势的变化是时下众多企业关注的焦点,这些变化能够为企业领导者带来切实有用的信息,而架构设计的主旨恰恰是从客户联系人、交易、运营等方面的信息中获取洞见,两者相辅相成。传统技术历来对企业从事件中获取洞见的速度有着诸多限制,比如用于记录、收集和处理此类事件的批处理 ETL(提取、转换、加载)。

事件驱动型架构 (EDA) 方兴未艾,作为一种 Serverless 化的应用概念对整个云原生架构具有着深远影响。当我们讨论到一个具体的架构时,首当其冲的是它的发展如何,是否具有技术先进性。为了保证文章更有带入感,我会先从我们熟悉的MVC架构,SOA架构谈起。所以这里我们先聊一聊关于消息事件领域的历史与发展趋势。

消息事件领域的发展趋势

上面这张图其实是去年云栖大会 EventBridge 产品发布时的一张宣讲图。早在 2018 年,Gartner 评估报告将 Event-Driven Model 列为10大战略技术趋势之一,事件驱动架构(EDA)将成为未来微服务的主流。该报告同时做出了以下断言:

  • 到 2022 年,事件通知的软件模型将成为超过 60% 的新型数字化商业的解决方案;
  • 到 2022 年,超过 50% 的商业组织将参与到事件驱动的数字化商业服务的生态系统当中;

很喜欢 George Santayana 在《 The Life of Reason》说的一句话 Those who fail to learn History are doomed to repeat it.(不懂历史的人注定会重蹈覆辙)。我们以史为鉴,来看看为什么会架构会演进到事件驱动。

上图,是我总结的关于架构演进时间轴线。架构本身没有优劣之分,它本身就是一组技术决策,决定后续项目的所有功能开发(框架,编码规范,文档,流程….),所以这里我们不谈选型好坏,只谈为什么会引入某些框架,这个框架解决了软件开发中的什么问题。

  • 单体架构:在单节点服务中,单体应用的所有模块都封装在单个进程运行,通信通过相同堆栈调用完成。这种模式下非常容易导致结构和关系不明确,难以对系统进行更改和重构。就像一个不透明的,粘稠的,脆弱的,僵硬的 Big Ball of Mud!
  • 分层架构:在经典的分层架构中,层以相当谨慎的方式使用。即一个层只能知道它下方层的数据。在随后的实际应用中,更多的方式是一个层可以访问它下面的任何层。分层架构解决了单体架构的的逻辑分离问题,每一层都可以被等效替换,是用层区分也更加标准化,同时一个层可以被几个不同/更高级别的层是用。当然,层也有比较明显的缺点,层不能封装掉一切,比如添加到UI的某个字段,可能也需要添加到DB,而且额外多余的层会严重损害系统性能。
  • MVC 架构:MVC 架构产生的原因其实很简单,随着业务系统的复杂性增加,之前所谓“全栈工程师”已经不适用大部分场景。为了降低前端和后台的集成复杂性,故而开始推广MVC架构。其中,Model 代表业务逻辑,View 代表视图层比如前端UI的某个小组件,Controller 提供View和Model 的协调比如将用户某项操作转为业务逻辑等。这里还有很多扩展架构,譬如 Model-View-Presenter ,Model-View-Presenter-ViewModel,Resource-Method-Representation,Action-Domain-Responder  就不在细说了,感兴趣的同学可以wiki搜索下。
  • EBI 架构:即Entity,Boundary(接口),Interactor (控制)。EBI架构将系统边界视为完整连接,而不仅仅是视图,控制器或接口。EBI的实体代表持有数据并结束相关行为的实际实体,很类似阿里云的 POP API。EBI 主要还是后端概念,他是与MVC相辅相成的。
  • 洋葱架构:洋葱架构是一种低耦合,高内聚的架构模型。所有的应用程序围绕独立的对象模型构建,内层定义接口外层实现接口,耦合方向向中心内聚,所有代码都可以独立与基础设施进行编译和运行。
  • SOA 架构:SOA 是Service Orientated Architure的缩写,即面向服务架构。表示每一个功能都是通过一个独立的服务来提供,服务定义了明确的可调用接口,服务之间的编排调用完成一个完整的业务。其实这个架构也是目前架构中最成熟的,日常使用最多的架构模式。

 

什么是 EDA 架构?

我们聊完之前全部的架构趋势后,在回过头看看什么是 EDA 架构。

EDA 事件驱动架构( Event-Driven Architecture ) 是一种系统架构模型,它的核心能力在于能够发现系统“事件”或重要的业务时刻(例如交易节点、站点访问等)并实时或接近实时地对相应的事件采取必要行动。这种模式取代了传统的“ request/response ”模型,在这种传统架构中,服务必须等待回复才能进入下一个任务。事件驱动架构的流程是由事件提供运行的。

上图其实很好的解释了EDA架构的模型,但是其实还不够明确,所以这里我们和单体架构一起对比看看他们之间差异。

在如上对比图中,我们其实可以较为清楚看到它与传统架构的区别。在一般传统架构中,创建订单操作发生后,一系列的操作其实都是通过一个系统完成的。而事件驱动的概念则是将全部操作都转换为 “事件” 概念,下游通过捕获某个 “事件” 来决定调用什么系统完成什么样的操作。

总结来看,事件驱动其实是将比较重要的业务时刻封装成“事件”,并通过某个EventBus将事件路由给下游系统。

那这样我们了解EDA架构的整个处理过程,但是还没解决这个所谓的“EventBUS”到底是啥样。

上图就是事件驱动的核心逻辑架构。是不是非常像某个传统 MQ?别着急,下面我会讲到这个架构的复杂部分。

讲完 EventBus,我们回过头来看“事件”,刚刚介绍中比较重要部分其实是将操作转换为某类事件进行分发。那这的事件我们怎么定义呢?

简单来看,其实事件就是状态的显著变化,当用户采取特定行动时触发。以4S店售卖汽车为例:

  • 当客户购买汽车并且其状态从 For Sale 变为 Sold 是一个事件。
  • 成功交易后,从帐户中扣除金额是一个事件。
  • 单击预订试驾后,从将预约信息添加到指定用户就是一个事件。

每个事件都可能触发一个或多个选项作为响应。

关于事件其实云原生 CNCF 基金会在2018年托管了开源 CloudEvents 项目,该项目旨在用统一和规范的格式来描述事件,来加强不同的服务、平台以及系统之间的互操作性。在该项目定义下,通用的事件规范是这样的:

事件主要由 Json 体构成,通过不同字段描述发生的事件。

 

EDA 架构的落地实践思考

在开始介绍落地实践时,我们先来看一个经典的 EDA 架构模型:

这是一个非常经典 EDA 订单架构,该架构主要使用了 EventBridge 和 FC 函数计算(如果不太熟悉 FaaS 的同学可以把FC节点当作 ECS 或 K8s 的某个POD节点),通过事件驱动各个业务进行协作。

所以这块的中心节点(EventBridge)其实有三个比较重要的能力:

  1. For Event Capturing(事件收集):具备采集事件的能力
  2. For Routing(事件路由):通过事件内容将事件路由分发至于下游的能力的
  3. For Event Processing(事件过滤/替换):对事件进行脱敏或初步过滤&筛选的能力

通常情况下,要实现这三个能力是比较困难的,比如: Event Capturing 可能需要熟悉 Dell Boomi, Snaplogic, MuleSoft, Dataflow, Apache Apex 等,Routing 部分可能通过 RocketMQ,RabbitMQ, ActiveMQ, Apache Kafka ,Event Processing 需要了解 Apache Storm, Apache Flink 。所以之前讲的逻辑架构其实非常理想,要想实现完成的 EDA 事件驱动还需要包括这些核心能力。

 

其实,从刚刚的架构中我们也能窥探到一些信息,EDA 架构其实看起来没有那么简单,那它有何优劣呢?下面我就简单罗列下EDA 架构在实践中的优势:

松耦合:事件驱动架构是高度松耦合且高度分布式的架构模型,事件的创建者(来源)只知道发生的事件,并不知道事件的处理方式,也关心有多少相关方订阅该事件。

异步执行:EDA 架构是异步场景下最适合的执行工具,我们可以将需要事件保留在队列中,直到状态正常后执行。

可扩展性:事件驱动架构可以通过路由&过滤能力快速划分服务,提供更便捷的扩展与路由分发。

敏捷性:事件驱动架构可以通过将事件分发至任何地方,提供更敏捷高效的部署方案。

当然,劣势也很明显:

架构复杂  事件驱动架构复杂,路由节点多,系统结成复杂,功能要求多。

路由分发难  事件路由及分发难,灵活的事件路由需要依赖强大的实时计算能力,对整体分发系统要求较高。

无法追踪  事件追踪是整个EDA架构保证,EDA 架构中往往很难追踪到事件处理状态,需要大量的定制化开发。

可靠性差  事件驱动由于需要多系统集成,可靠性通常较差,且交付无法保障。

 

阿里云 EventBridge 如何解决 EDA 场景下的困境

针对 EDA 场景下面临的这些问题,阿里云推出了 EventBridge,一款无服务器事件总线服务,其使命是作为云事件的枢纽,以标准化的 CloudEvents 1.0 协议连接云产品和应用,应用和应用,提供中心化的事件治理和驱动能力,帮助用户轻松构建松耦合、分布式的事件驱动架构;另外,在阿里云之外的云市场上有海量垂直领域的 SaaS 服务,EventBridge 将以出色的跨产品、跨组织以及跨云的集成与被集成能力,助力客户打造一个完整的、事件驱动的、高效可控的上云体验。

架构复杂:提供业内通用的  Source ,Buses,Rules,Targets  模块管理能力,同时支持 EventBus 和 EventStream 两种模式。大幅度降低事件驱动架构难度。

路由分发:EventBridge 通过事件规则驱动,支持8大事件模式,4重转换器,满足路由分发的全部诉求。

无法追踪:独家提供事件追踪能力,事件分析/查询能力。为用户完善整体事件链路。

可靠性差:支持DLQ/重试机制,大幅度保证由于用户下游系统导致的事件故障与延迟。

同时,在此基础上 EventBridge 支持82种阿里云产品,847 种事件类型。

更多产品功能介绍,可访问 EventBridge官网

 

阿里云 EventBridge 更多场景介绍

1. 经典EDA事件驱动:事件总线(EventBridge)最重要的能力是通过连接应用程序,云服务和 Serverless 服务构建 EDA(Event-driven Architectures) 事件驱动架构,驱动应用与应用,应用与云的连接。

2. 流式 ETL 场景:EventBridge 另一个核心能力是为流式的数据管道的责任,提供基础的过滤和转换的能力,在不同的数据仓库之间、数据处理程序之间、数据分析和处理系统之间进行数据同步/跨地域备份等场景,连接不同的系统与不同服务。

3. 统一事件通知服务:EventBridge 提供丰富的云产品事件源与事件的全生命周期管理工具,您可以通过总线直接监听云产品产生的数据,并上报至监控,通知等下游服务。

 

更多 EDA 场景欢迎各位探索。

预告:10月16日,本人将在北京为大家分享 EventBridge 的相关落地与EDA场景的介绍,欢迎大家前来观看。。



114 thoughts on “EDA 事件驱动架构与 EventBridge 二三事”

  • Undeniably believe that which you stated. Your favorite reason appeared to be on the net the easiest thing to be aware of. I say to you, I definitely get irked while people consider worries that they plainly do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people could take a signal. Will likely be back to get more. Thanks

  • Howdy! I could have sworn I’ve been to your blog before but after going through some of the posts I realized it’s new to me. Nonetheless, I’m definitely happy I came across it and I’ll be book-marking it and checking back regularly!

  • The very core of your writing whilst appearing agreeable originally, did not really work very well with me after some time. Somewhere within the sentences you managed to make me a believer but just for a short while. I nevertheless have a problem with your leaps in logic and one might do well to help fill in all those breaks. In the event that you actually can accomplish that, I could undoubtedly be amazed.

  • hello there and thank you for your info ? I have definitely picked up anything new from right here. I did however expertise several technical issues using this website, as I experienced to reload the website many times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will sometimes affect your placement in google and could damage your high-quality score if advertising and marketing with Adwords. Well I am adding this RSS to my email and can look out for a lot more of your respective fascinating content. Ensure that you update this again very soon..

  • When I initially left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I receive 4 emails with the same comment. Perhaps there is a means you can remove me from that service? Thank you.

  • Aw, this was a very good post. Finding the time and actual effort to produce a really good article… but what can I say… I hesitate a whole lot and never seem to get anything done.

  • Youre so cool! I dont suppose Ive read anything like this before. So nice to search out any person with some unique thoughts on this subject. realy thanks for beginning this up. this website is one thing that’s wanted on the net, somebody with just a little originality. useful job for bringing one thing new to the internet!

  • Thank you for sharing superb informations. Your website is very cool. I’m impressed by the details that you have on this web site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my friend, ROCK! I found simply the info I already searched everywhere and simply could not come across. What a perfect website.

  • One thing I would really like to say is the fact that before obtaining more laptop or computer memory, consider the machine in which it could be installed. In the event the machine can be running Windows XP, for instance, the memory ceiling is 3.25GB. Using a lot more than this would purely constitute any waste. Make sure that one’s mother board can handle the actual upgrade volume, as well. Thanks for your blog post.

  • I have learned result-oriented things through your site. One other thing I would like to say is that newer pc os’s are inclined to allow far more memory to be used, but they additionally demand more ram simply to work. If your computer cannot handle a lot more memory along with the newest application requires that memory increase, it usually is the time to buy a new Personal computer. Thanks

  • I have realized that car insurance firms know the motors which are liable to accidents and various risks. Additionally, these people know what types of cars are given to higher risk as well as higher risk they may have the higher a premium price. Understanding the very simple basics connected with car insurance will assist you to choose the right style of insurance policy that could take care of your family needs in case you get involved in any accident. Thank you for sharing the ideas on your own blog.

  • I like the valuable information you provide in your articles. I will bookmark your weblog and check again here frequently. I’m quite certain I?ll learn lots of new stuff right here! Good luck for the next!

  • Thanks for your write-up. What I want to point out is that while looking for a good internet electronics go shopping, look for a web site with complete information on critical indicators such as the security statement, basic safety details, any payment methods, along with terms and also policies. Always take time to see the help along with FAQ pieces to get a far better idea of the way the shop functions, what they are capable of doing for you, and how you can use the features.

  • Thanks for your useful post. Through the years, I have come to understand that the actual symptoms of mesothelioma cancer are caused by this build up connected fluid between the lining of the lung and the upper body cavity. The sickness may start in the chest area and get distributed to other parts of the body. Other symptoms of pleural mesothelioma cancer include losing weight, severe inhaling trouble, temperature, difficulty swallowing, and irritation of the neck and face areas. It ought to be noted that some people living with the disease never experience almost any serious indicators at all.

  • Thank you for the sensible critique. Me & my neighbor were just preparing to do some research about this. We got a grab a book from our area library but I think I learned more from this post. I’m very glad to see such magnificent info being shared freely out there.

  • I have noticed that credit restoration activity needs to be conducted with techniques. If not, you will probably find yourself damaging your ranking. In order to realize your aspirations in fixing your credit ranking you have to ascertain that from this minute you pay your complete monthly dues promptly prior to their slated date. It is definitely significant simply because by certainly not accomplishing that area, all other activities that you will choose to adopt to improve your credit ranking will not be powerful. Thanks for expressing your strategies.

  • Thanks for your article on this website. From my own personal experience, there are times when softening upwards a photograph may provide the photography with an amount of an artistic flare. Often times however, that soft cloud isn’t just what you had in your mind and can quite often spoil an otherwise good photograph, especially if you intend on enlarging that.

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

  • I?ll immediately grasp your rss as I can not in finding your email subscription hyperlink or e-newsletter service. Do you have any? Please permit me realize in order that I may subscribe. Thanks.

  • I appreciate, lead to I found exactly what I used to be having a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye

  • Hello there, I found your website by means of Google at the same time as looking for a comparable matter, your website came up, it seems great. I’ve bookmarked it in my google bookmarks.

    • Nice weblog right here! Also your web site quite a bit up very fast! What web host are you the usage of? Can I am getting your affiliate link in your host? I desire my website loaded up as quickly as yours lol

    • Thanks for giving your ideas right here. The other point is that any time a problem arises with a laptop motherboard, people should not take the risk regarding repairing this themselves because if it is not done correctly it can lead to permanent damage to the entire laptop. Most commonly it is safe to approach your dealer of your laptop for the repair of motherboard. They have technicians who may have an competence in dealing with laptop computer motherboard issues and can make the right diagnosis and perform repairs.

    • Thanks a bunch for sharing this with all of us you actually know what you’re talking about! Bookmarked. Please also visit my website =). We could have a link exchange arrangement between us!

  • Have you ever considered about adding a little bit more than just your articles? I mean, what you say is important and all. But imagine if you added some great pictures or video clips to give your posts more, “pop”! Your content is excellent but with pics and videos, this blog could definitely be one of the very best in its field. Terrific blog!

    • I will immediately grab your rss feed as I can’t in finding your email subscription link or e-newsletter service. Do you’ve any? Please allow me recognize in order that I could subscribe. Thanks.

    • Thanks for the recommendations on credit repair on this excellent site. The things i would offer as advice to people is always to give up the particular mentality that they’ll buy currently and pay out later. Like a society most of us tend to try this for many things. This includes vacations, furniture, and items we’d like. However, you’ll want to separate your current wants out of the needs. As long as you’re working to fix your credit score actually you need some sacrifices. For example you are able to shop online to save money or you can click on second hand outlets instead of expensive department stores with regard to clothing.

    • I’d also like to state that most individuals that find themselves without having health insurance are normally students, self-employed and people who are unemployed. More than half of those uninsured are under the age of 35. They do not feel they are in need of health insurance since they are young and healthy. Their income is frequently spent on real estate, food, along with entertainment. Some people that do work either entire or not professional are not made available insurance by means of their work so they proceed without due to the rising cost of health insurance in the states. Thanks for the concepts you write about through this web site.

    • Thanks for these guidelines. One thing I should also believe is that often credit cards providing a 0 monthly interest often entice consumers in zero rate, instant authorization and easy internet balance transfers, however beware of the top factor that will probably void your own 0 easy road annual percentage rate and also throw anybody out into the terrible house rapidly.

    • Hey very nice web site!! Guy .. Beautiful .. Amazing .. I will bookmark your site and take the feeds also?I’m satisfied to search out numerous useful information right here in the submit, we’d like develop extra strategies on this regard, thank you for sharing. . . . . .

    • I?ve been exploring for a little bit for any high quality articles or blog posts in this sort of house . Exploring in Yahoo I at last stumbled upon this web site. Reading this information So i?m happy to show that I’ve an incredibly good uncanny feeling I found out exactly what I needed. I most for sure will make sure to do not fail to remember this web site and give it a glance on a relentless basis.

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

    • I have been browsing on-line greater than three hours nowadays, yet I never discovered any interesting article like yours. It?s lovely price enough for me. Personally, if all webmasters and bloggers made just right content material as you did, the internet will be much more useful than ever before.

  • Hmm is anyone else having problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.|

    • What i don’t understood is actually how you are not actually much more well-liked than you may be now. You’re so intelligent. You realize therefore significantly relating to this subject, produced me personally consider it from numerous varied angles. Its like women and men aren’t fascinated unless it is one thing to do with Lady gaga! Your own stuffs nice. Always maintain it up!

  • Thanks a lot for sharing this with all of us you actually know what you’re speaking approximately! Bookmarked. Please additionally talk over with my website =). We could have a hyperlink trade arrangement among us|

  • What’s Happening i’m new to this, I stumbled upon this I’ve discovered It positively useful and it has helped me out loads. I’m hoping to contribute & help other users like its helped me. Good job.|

    • Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a little bit, but other than that, this is wonderful blog. A fantastic read. I’ll definitely be back.

  • What i do not realize is in reality how you’re not actually a lot more neatly-appreciated than you may be now. You are very intelligent. You recognize therefore significantly in the case of this subject, produced me for my part imagine it from a lot of varied angles. Its like men and women are not interested unless it is something to do with Girl gaga! Your personal stuffs great. All the time care for it up!|

    • Thanks for sharing your ideas on this blog. Additionally, a delusion regarding the financial institutions intentions while talking about foreclosure is that the bank will not have my installments. There is a certain quantity of time that this bank is going to take payments every now and then. If you are far too deep inside hole, they’re going to commonly desire that you pay the particular payment completely. However, i am not saying that they will have any sort of installments at all. If you and the traditional bank can manage to work something out, the particular foreclosure process may halt. However, in case you continue to skip payments in the new strategy, the property foreclosures process can just pick up exactly where it was left off.

    • I have noticed that online education is getting preferred because accomplishing your college degree online has become a popular alternative for many people. A huge number of people have not really had a chance to attend a normal college or university nonetheless seek the elevated earning potential and career advancement that a Bachelor’s Degree provides. Still other folks might have a qualification in one training but want to pursue a thing they now possess an interest in.

发表评论

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

25 ÷ = 5