[英]Axon framework - using separate Mongo collection of domain events for each aggregate root
We worry about performance of using single Mongo collection (domainevents) for domain events. 我们担心将单个Mongo集合(domainevents)用于域事件的性能。
Is it good idea to split domainevents collection to separate collections for each aggregate root? 将domainevents集合拆分为每个聚合根的单独集合是个好主意吗?
We have query model, that is generated based on events from multiple aggregate roots. 我们有查询模型,它是基于来自多个聚合根的事件生成的。 If we split domainevents to multiple collections, will Axon still preserve the order of events across aggregate roots?
如果将domainevents拆分为多个集合,Axon是否仍会保留聚合根中事件的顺序?
And is it generally good idea to do this? 这样做通常是个好主意吗?
There are a few questions here, that require different knowledge to answer. 这里有一些问题,需要不同的知识来回答。 I am not a MongoDB expert, but do know my way around Axon, being the founder.
我不是MongoDB专家,但确实知道我是Axon的创始人。
The MongoEventStore
in Axon doesn't natively support multiple collections for the domain events. Axon中的
MongoEventStore
本身不支持域事件的多个集合。 So the answer to your order preservation query is: it won't work, unless you build support for it yourself. 因此,订单保留查询的答案是:除非您自己为其建立支持,否则它将不起作用。 And then the order is guaranteed depending on how you built it.
然后根据您的构建方式保证订单。
You can also consider sharding the Mongo Collection. 您也可以考虑分片Mongo Collection。 Using the aggregate identifier as shard key will allow you to guarantee that queries for an aggregate stream hit a single shard.
使用聚合标识符作为分片键将使您能够保证对聚合流的查询命中单个分片。 According to the documentation, it is recommended to avoid queries that do not include this shard key.
根据文档,建议避免查询不包含此分片键的查询。
The best approach to dealing with this performance issue, is to do a performance test. 解决此性能问题的最佳方法是进行性能测试。 See how latency and throughput are affected as the size of the collection grows.
了解随着集合大小的增长,延迟和吞吐量如何受到影响。 Adding the right indexes may help.
添加正确的索引可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.