Saga concurrency

Hi,

I’m trying to get a better understanding of concurrency, specifically for sagas. I’ve read the documentation at https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#parallel-processing.
However, I don’t fully understand the concept of a multi threaded processor vs sequencing policies. The documentation mentions it is not possible to define a sequencing policy for a saga since each saga instance needs to get its events in order. I can however make a processor multi threaded and this appears to be true for both processors linked to regular event handlers and processors linked to sagas. So what does that actually mean? Without a multi threaded processor I can only fetch one saga instance from the database at any given time? And if I define e.g. 4 threads for my processor I will be able to interact with 4 saga instances at the same time?

Regards,
Jens

Hi Jens,

the number of threads basically defines how many processes will handle events concurrently. For regular event handlers, the sequencing policy dictates which thread is responsible for handling which events, so that you have guarantees that certain events will only be handled after handling another one has completed.

For Sagas, it wouldn’t make sense to define a sequence policy. The Saga instance is the sequence policy, meaning the instances are “divided” among the threads. Each thread will only invoke a Saga instance if that Saga is “owned” by that specific thread. So yes, having 4 threads means have can have 4 Sagas concurrently executed.

Cheers,