用于微服务编排的 AWS Kinesis

AWS Kinesis for Microservice Choreography

我正在尝试使用 CQRS、DDD 和事件溯源概念为在线商店开发微服务。我将 AWS Kinesis 视为事件流。我认为这对编排的微服务有好处。我有 2 项服务,客户数据服务和订购系统服务。我想查看每个客户的未付款订单总数和订单总额。因此,我应该将 orderCreated 事件和 orderPaid 事件发送到客户数据服务,并重新计算相关客户的未支付订单总额和订单总额。

我可以将订购系统事件放入 AWS Kinesis 并在客户的命令端服务中收听吗?我应该将事件(orderCreated 和 orderPaid 事件)从 AWS Kinesis 保存到客户命令端服务中的数据库吗?或者只更新客户查询端服务是否可以?我应该使用 AWS Lambda 作为事件处理器吗?你能给我一些关于这个模型的最佳实践吗?

提前致谢。

I looked to AWS Kinesis as event stream. I think it would be good for choreographed microservices.

我不认为这是 Kinesis 设计的用例;看到这个 overview by Aditya Krishnan. Or this previous question on stack overflow.

Should I persist the events (orderCreated and orderPaid event) from AWS Kinesis to database in customer command-side service?

在我看来,问题在于:您真的不希望事件泄露给订阅者然后不出现在记录簿中。所以通常的顺序是将事件放入持久存储中,只有在您获得写入确认(这是 "acknowledgment that we've reached our minimum durability guarantee" 的代理)之后,您才开始将事件共享出去。

所以大多数设计与您建议的顺序相反 - 首先是持久存储(数据库),其次是发布。但是你正在失去延迟;在商店完成之前,订阅者无法看到该事件。根据您的设计,您也许可以通过批量读取来弥补其中的一部分。

We have tried the SQS and SNS. But, the performance is not good enough. It takes about 5 seconds to publish and consume the events.

嗯,根据我在 Kinesis 的建议中看到的内容,看起来您不会超过 order of magnitude;他们似乎推荐完整的管道而不是快速的管道。