简体   繁体   English

Airflow 微服务架构

[英]Airflow Architecture for Microservices

My current platform architecture has a microservice for downloading/collecting data, a microservice for ETL and another microservice to process some complex SQL scripts.我当前的平台架构有一个用于下载/收集数据的微服务、一个用于 ETL 的微服务和另一个用于处理一些复杂 SQL 脚本的微服务。

I want to use Airflow to schedule and monitor workflows.我想使用 Airflow 来安排和监控工作流程。 I tried it and it worked very nice.我试过了,效果很好。 However, I have to put all functionalities as tasks into one container of Airflow;但是,我必须将所有功能作为任务放入 Airflow 的一个容器中; and this doesn't follow current microservice architecture.这不遵循当前的微服务架构。 What I wanted is to use Airflow as a scheduler and communicate with other microservices.我想要的是使用 Airflow 作为调度器并与其他微服务通信。

I want to ask: What is the best way to use Airflow with microservices?我想问:在微服务中使用 Airflow 的最佳方式是什么? Should I use tasks in DAGs to communicate with microservices (publish messages and microservices will subscribe)?我是否应该使用 DAG 中的任务与微服务进行通信(发布消息和微服务将订阅)?

DAG can be described as below. DAG 可以描述如下。 Please note that there're other tasks like validation after downloading data but I've just simplified it.请注意,下载数据后还有其他任务,例如验证,但我只是对其进行了简化。 DAG有向无环图

A workflow engine like Apache Airflow and an architectural paradigm like microservices are inherently antithetical.像 Apache Airflow 这样的工作流引擎和像微服务这样的架构范式本质上是对立的。 Both are perfectly legitimate, both valuable, and both have pros & cons, but they are two completely different approaches to building distributed systems.两者都是完全合法的,都很有价值,并且都有优点和缺点,但它们是构建分布式系统的两种完全不同的方法。

You hit on it yourself in your comment:您在评论中自己点击了它:

..if I gather all functionalities of those microservices into one under airflow container, that would be monolithic. ..如果我将这些微服务的所有功能集中到 airflow 容器下,那将是单片的。

The microservices principle being violated here is referred to as " smart endpoints, dumb pipes ".这里违反的微服务原则被称为“ 智能端点,哑管道”。

The idea being 'Smart Microservice A' should communicate with 'Smart Microservice B' (be that directly or indirectly) and that you should not have 'Dumb Microsevice A' and 'Dumb Microservice B' wired together by 'Smart Workflow Service'. “智能微服务 A”的想法应该与“智能微服务 B”(直接或间接)通信,并且您不应该通过“智能工作流服务”将“哑微服务 A”和“哑微服务 B”连接在一起。

The latter is more of an Enterprise Service Bus (ESB) or a Service Oriented Architecture (SOA) design.后者更像是企业服务总线 (ESB)面向服务的架构 (SOA)设计。

Again, ESBs and SOAs have their place, but a microservices architecture is a different kind of architecture and is inherently incompatible.同样,ESB 和 SOA 也有自己的位置,但微服务架构是一种不同的架构,本质上是不兼容的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM