简体   繁体   English

存储和转发具有多个微服务实例的设计模式

[英]Store and forward design pattern with multiple instances of a microservice

I am designing a service that will be receiving requests which must only be executed exactly once (can be received more than once due to unique id presence). 我正在设计一个服务,它将接收只能执行一次的请求(由于唯一的id存在,可以多次接收)。

The flow is: 流程是:

outside world -> HTTP -> [A set of instance of Myservice] -> HTTP -> Vendor services 外部世界 - > HTTP - > [一组Myservice实例] - > HTTP - >供应商服务

So, I am receiving a bunch of requests over HTTP and I am looking to do some transformation, checking, store the request in a database and send to to the vendor services via HTTP too. 所以,我通过HTTP收到一堆请求,我希望进行一些转换,检查,将请求存储在数据库中,并通过HTTP发送给供应商服务。

My question is: 我的问题是:

What is an effective way to achieve a store and forward pattern in my service ie receive the request and store it immediately, therefore acking it to the "outside world" immediately and then in my own time forward it to the destination service, retrying as many times as needed? 什么是在我的服务中实现存储和转发模式的有效方式,即接收请求并立即存储它,因此立即将其应用到“外部世界”,然后在我自己的时间将其转发到目标服务,重试尽可能多的根据需要的时间?


Problems: 问题:

  • What if one of the instances of myservice goes down while it is sending the request to the vendor service? 如果myservice的一个实例在向供应商服务发送请求时发生故障,该怎么办?
  • How will I monitor if there are a bunch of request that have not been forwarded? 如果有一堆未被转发的请求,我将如何监控?
  • How to avoid another orchestration service? 如何避免另一个业务流程服务?
  • How to avoid another single instance service that is effectively watching the database and forwarding any requests that have not been forwarded. 如何避免另一个有效监视数据库并转发任何尚未转发的请求的单实例服务。
  • How to minimise external dependencies - eg I am aware some sort of queue here might help this issue, but I am trying to see if I can avoid that. 如何最小化外部依赖 - 例如我知道这里的某种队列可能有助于解决这个问题,但我想知道我是否可以避免这种情况。

I would advise against NIH syndrom and take a dependency on a mature technology that delivers all your reliability requirements out of the box. 我建议不要使用NIH综合症,并依赖于成熟的技术,这些技术可以满足您的所有可靠性要求。

Cadence Workflow is capable of supporting your use case with minimal effort. Cadence Workflow能够以最小的努力支持您的用例。

Cadence offers a lot of features that are hard to match building custom task orchestration solution: Cadence提供了许多难以匹配构建自定义任务编排解决方案的功能:

  • Built it exponential retries with unlimited expiration interval 构建指数重试,具有无限的到期间隔
  • Failure handling. 失败处理。 For example it allows to execute a task that notifies another service if both updates couldn't succeed during a configured interval. 例如,如果在配置的间隔期间两个更新都无法成功,则它允许执行通知另一个服务的任务。
  • Support for long running heartbeating operations 支持长时间运行的心跳操作
  • Ability to implement complex task dependencies. 能够实现复杂的任务依赖性。 For example to implement chaining of calls or compensation logic in case of unrecoverble failures ( SAGA ) 例如,在无法发生故障的情况下实现呼叫链接或补偿逻辑( SAGA
  • Gives complete visibility into current state of the update. 提供对当前更新状态的完全可见性。 For example when using queues all you know if there are some messages in a queue and you need additional DB to track the overall progress. 例如,当使用队列时,您知道队列中是否有一些消息,并且您需要额外的数据库来跟踪整体进度。 With Cadence every event is recorded. 使用Cadence记录每个事件。
  • Ability to cancel an update in flight. 能够取消飞行中的更新。
  • Distributed CRON support 分布式CRON支持

See the presentation that goes over Cadence programming model. 请参阅Cadence编程模型的演示文稿

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

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