Event Search Model / CQRS - Forecasts

I have a microservice-based application running on AWS Lambda. Two of the microservices, the most important of which, use event-sourcing / cqrs.

Background: (it is also for me to organize my thoughts)

I use this library and save events in DynamoDB and projections in AWS S3.

Part of the record works like a charm: each command invocation loads the current state of the aggregate from DynamoDB (by triggering events through the handler and / or loading the cached aggregate), it decides to accept or reject the command based on some business logic, then writes to DynamoDB with KeyConditionExpression: 'aggregateId = :a AND version >= :v', where version represents the number of events processed for this aggregate. If there is a conflict, the recording failed. It seems like a good system to me!

Each event is then passed to SNS (the topic name is the name of the service), so other services can respond to the event if they want.

The part that I really struggle with is the read. Predictions are stored in S3 and tagged with the last commitId processed for each event source. When a read request arrives, it loads the entire projected state from S3 (for all aggregates), queries the event sources for all new events, calculates the last state (again for all aggregates), and writes the updated object to S3 if it is newer) and returns relevant parts of the state based on query parameters.

My problem: (or one of them)

I think I'm making the wrong predictions.

, . . , (.. ), , (, ).

, , (< 100k ), , .

- . aggregateIds , ! !

, , + , , .

+4
2

, .

; ,

, S3 ( ), ,

, . , , , , .

, . , , .

, : , S3. , , , .

.

- ? , ? - , ?

, , .

, ... - ; , ( 15 , , ) - (, , , ). , .

, , .

. , , , , .

, , , A{id:7} B{id:9}. ( ) - , metadata:{A:{id:7, version:21}, B:{id:9, version:19}}. , , , .

+6

, :

, . , , . , 0. 0. , , ​​, , .

, . , . .

. - , . "" , .

, . Shuttle.Recall #, .

+4

Source: https://habr.com/ru/post/1689325/


All Articles