Reducing the number of token updates

Hello everyone,

we currently use Axon Framework 4.5.3 in a Spring Boot application with a JPA Event Store.

There is only one instance of the application running at the same time (no clustering).

In our application events happen rarely… we do not have hundreds of events each second… it’s more like one event every minute.

There are several TrackingEventProcessors, each of them is configured to have 4 segments.

As we have a lot of event processors we experienced a lot of interaction with the database as every token for every segment is updated every second.

Example: We have 20 Processors, each has 4 segments → 80 update queries per second although the systems idles (aka no events occur).

What we did to reduce the load:

  • We increased the JpaTokenStores’ claimTimeout from 10 to 30 seconds.
  • We increased the TrackingEventProcessors’ EventAvailabilityTimeout from 1 to 20 seconds.

So far we did not experience any bad effects. Events are handled immediately and the token is updated every 20 seconds instead of every second… meaning that we reduced the number of update queries by 95%.

This change might have some impact when running in a clustered environment as a node claims a token for up to 30 seconds instead of 10 seconds.

But do you see any negative consequences in a single node environment?

Thanks for the answers!

Kind regards
Oliver

I case someone stumbles upon this question, I would like to answer it by myself.

Turned out that the increasment of the EventAvailabilityTimeout to 20 seconds had some impacts:

At application shutdown …

  1. … it takes up to the configured EventAvailabilityTimeout until all the streaming event processors are stopped
  2. … a lot of exceptions are thrown because the connection pool is shut down after waiting 5 seconds for the processors to be stopped. As it takes longer to stop the processor the connection pool is closed before the processors are stopped. This results in a lot of exceptions.

There is a corresponding issue at GitHub: Make the shutdown timeout configurable · Issue #1981 · AxonFramework/AxonFramework · GitHub