ing-bank/baker

Does Baker automatically remove old events from its database, or do these grow forever?

garethrandall opened this issue · 2 comments

Baker uses Akka persistence to store events. Once a task has completed (this may be the wrong terminology), are the events related to that task eventually removed from the database automatically, or will they persist forever meaning that the database eventually grows to enormous size?

Also, does the size of the database (number of stored events) affect start-up time of the Baker application when it re-reads its events?

Thank you.

Hello Gareth,

Great questions, let me give you some more information.

Baker event sources two actor.

RecipeManager
The first is the RecipeManager actor.
This actor stores all recipes that have been added.
At the moment these are never removed from the datastore.
We do not foresee an issue with ths since it only stores the recipes.
In the future we want to add capabilities to remove old recipes.

This actor is started once Baker is started.
So in theory if there are a lot of recipes this could impact start time.
We have not seen this ourselves.

ProcessInstance
A ProcessInstance actor is created each time an process is baked.
This actor event sources all events that happen for the instance.
The Recipe dictates with the retention period how long the data will be kept in the datastore.
By default this is not set so the datastore will keep growing indefinitly.
I strongly advice to always configure a retention period on your Recipe if you use a datastore.
This can be done with:

.withRetentionPeriod(Duration.ofDays(7))

Baker only starts a ProcessInstance actor once it is needed.
This can be once a sensory event is fired to it or if a inquire is done on the process.
It is kept in memory for the configured idle-timeout in Baker (default 5 minutes).
On startup Baker checks what ProcessInstances should be active.
In theory if a lot of ProcessInstances need to be active on startup this can impact the startup time.
Old processes are not loaded in so they do not have any impact on the startup time.

I hope this answers your questions!

Regards,

Tim Linschoten

Closing as it seems to be answered :)