Temporal Blog 09月30日
重新思考分布式系统:事件驱动架构的局限性
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

文章探讨了事件驱动架构(EDA)在构建分布式系统时的局限性,以哥白尼的视角转变为例,说明简化系统模型的重要性。文章指出EDA在扩展时会出现API缺失、紧耦合、逻辑分散、调试困难、状态机泛滥、延迟增加、竞争条件和系统可升级性差等问题。相比之下,持久执行(Durable Execution)提供了一种更好的抽象方法,通过集中定义业务逻辑、统一状态管理、支持系统崩溃恢复和灵活设计流程,简化分布式系统的构建和维护。

🌍 文章以哥白尼的视角转变为例,说明了简化系统模型的重要性,指出过于复杂的模型在实际应用中难以理解和维护,而改变视角可以显著简化系统。

📈 事件驱动架构(EDA)在构建分布式系统时,虽然看起来优雅,但在扩展时会暴露出诸多问题,如API缺失导致接口不明确,事件驱动导致系统紧耦合,业务逻辑分散难以管理。

🔄 文章详细列举了EDA的七大主要问题:缺乏明确API、系统紧耦合、业务逻辑分散、调试困难、状态机泛滥、延迟增加和竞争条件,这些问题严重影响了系统的可维护性和可靠性。

🔄 持久执行(Durable Execution)作为一种替代方案,通过集中定义业务逻辑、统一状态管理、支持系统崩溃恢复和灵活设计流程,有效解决了EDA的诸多痛点,提供了更可靠和可维护的分布式系统构建方式。

🔄 文章强调,从EDA转向持久执行不仅是架构模式的转变,更是对系统构建方式的根本性变革,有助于构建更可靠、更易于理解和扩展的软件系统。

Rethinking Distributed Systems: Why Events Fall Short#

Changing how you think about a system can have big implications. Consider the example of Copernicus, where a “simple” change of perspective holds a valuable lesson for all of us.

In the early sixteenth century, Copernicus realized that existing models of the solar system were overly complicated. They looked beautiful, but when it came to figuring out where things might be relative to others, it was a rather difficult working model:

He believed that those models could be dramatically simplified by changing the frame of reference. Rather than modeling everything with Earth at the center of the universe, by placing the Sun at the center you could produce a simpler system that was far easier to understand:

This new model drastically simplified the understanding of planetary movements and enabled a whole new series of discoveries and developments that we now call the Copernican Revolution. This simple change of perspective holds a valuable lesson for all of us; changing how you think about a system can have big implications.

Simpler Diagrams are Better Diagrams#

Event-Driven Architecture (EDA) is one of the most common patterns in modern applications built with microservices. Like the model with Earth at the center, some architecture diagrams look rather beautiful. Once you are forced to work with them at scale, however, many developers discover they’re extraordinarily complex, fragile, and frustrating. Consider this relatively simple Payment Accumulation archihttps://temporal.io//images.ctfassets.net/0uuz8ydxyd9p/7uMNFmB2ZXvxpfgC2eulpD/c1058c26023551c7a2d1be88211c026c/drew-eda-blog-diagram-without-temporal.png-eda-blog-diagram-without-temporal.png" alt="drew-eda-blog-diagram-without-temporal">

Copernicus’ Insight: Try Shifting the Center#

If you shift the center of your world view away from events, you might help be able to reduce the intricacy of your software systems. This, in turn, could unlock and unblock projects that are hopelessly complicated by an overly convoluted EDA system.

Here’s how that same Paymenthttps://temporal.io//images.ctfassets.net/0uuz8ydxyd9p/5JfPz02xtyVjkgtwbODVde/8cc6ebd63a9a29a75d938ceda3607236/drew-eda-blog-diagram-with-temporal.png75d938ceda3607236/drew-eda-blog-diagram-with-temporal.png" alt="drew-eda-blog-diagram-with-temporal">

Common Problems of Event-Driven Architecture#

Event-Driven Architecture is a common approach for building distributed applications. However, EDA has major pitfalls, especially when scaled:

    No APIs: Implementing EDA usually leads to the loss of clear, well-defined APIs. Events lack the documentation and structure that APIs provide, leading to ambiguity about which events each service consumes and produces. Tightly Coupled: Despite the perception of loose coupling, EDA systems are often effectively highly coupled, as changes in one service can cause unintended consequences throughout the system. Events are effectively global variables, and changes to those events and event formats can break services throughout the system. For more on this, see Event-Driven Systems and the Truth About "Loosely Coupled" Architectures. Scattered Logic: Business logic becomes fragmented and spread across many different services which makes it difficult to understand and maintain. Poor Debuggability: If an event handler doesn’t happen as expected, tracing through the prior events to figure out where the chain got broken is tedious and requires a lot of careful investigation. And, often, understanding what that chain of events might include can be its own non-trivial research project. Proliferating Ad-hoc State Machines: Each service becomes an ad-hoc state machine, complicating state management. This state is dispersed across different systems and events, making it hard to get a clear picture of what is happening and why. Increased Latency: The queuing and infrastructure overhead necessary to manage event flows can introduce considerable latency. Race Conditions: Unless you use the outbox pattern to guarantee data consistency, you will have race conditions between queues and databases that can be extremely difficult to diagnose and troubleshoot. System Upgradability: Upgrading EDA systems is extremely difficult because of poorly defined and understood dependencies and scattered state management.

Durable Execution: A Better Abstraction#

Durable Execution offers a compelling alternative to event-driven architecture, addressing many of its shortcomings. Platforms like Temporal use this approach to provide more resilient and maintainable distributed systems.

Collect Your Business Logic and Simplify Your Life With Durable Execution, developers define business logic with code that lives in one central place, significantly improving understanding and debuggability.

Manage State Consistently Durable Execution handles state management, retries and more so that network outages, flaky endpoints, long-running processes and other transient failures don’t overwhelm your system with the complexity of managing unreliable processes.

Survive Crashes with Grace Durable Execution inherently supports resilience. The execution state is preserved even in the face of process crashes or system outages, allowing the app to resume from where it left off. This capability ensures consistency and reliability, making operations more dependable and resilient.

Design Processes Flexibly Durable Execution handles long-running and intricate processes. This flexibility supports synchronous and asynchronous processes, accommodating a wide range of application needs. Developers can build systems that span hours, days, or even longer periods without sacrificing reliability.

Embracing a New Approach#

Shifting from Event-Driven Architecture to Durable Execution is more than just a different way to model systems; it's a fundamental change in how you can build reliable and maintainable software. By addressing the shortcomings of event-driven designs and offering a more intuitive and effective framework, Durable Execution empowers you to create distributed systems that are easier to understand, maintain, and expand.

As we seek to build better, more reliable systems, having the right frame of reference can make a big difference. Yes, you can model the whole universe as revolving around Earth, but if you take a page from Copernicus, you might find that changing your frame of reference will make your system much, much easier.

Read next: Event-Driven Architectures - A better way forward ›

Ready to Rethink EDA?#

Whether you're just starting with events or already have built an event-driven system and feel the pains, we encourage you to check out Temporal and see how it can simplify your architecture and code and make building distributed systems durable, flexible, and clear:

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

分布式系统 事件驱动架构 持久执行 哥白尼视角 系统架构 微服务 系统可靠性
相关文章