Question regarding updating projections in production

Hello ESDB team! We had a question regarding updating projections and would appreciate some guidance here.

What are the correct ways to update a projection while maintaining the projection state? I can see a few options:

  1. Replay all of the events in the stream
    → If we have many long streams this seems less than ideal

  2. Create closing book events, archive the previous and then update the projection
    → Still needs to process a lot of events if we have 1mil+ streams

  3. Some other option?

Are these the recommended ways or is there anything more efficient? Do you have any resources about best practices for updating the projection when you may be deploying a new version of the app multiple times per day?

Thanks all for the help!

Hi,

What are you projecting into? What do you mean specifically when you say “update a projection while maintaining projection state”?

Regards,
Yves

Hello Yves, thanks for the reply!

We are implementing an accounting system to keep track of an account’s current balance, along with some other account related information. The input events represent actions that change the current balance, such as deposits and withdrawals, and we have a projection that makes balance calculations and emits into a result stream for each account. (When we say the “projection state”, we are referring to the projection output state that gets updated with each input event that gets read by the projection.) We finally write these updated results into our read model which exists in MongoDB.

Our main questions are about updating the code for such projection.

  • We are planning to use “PUT https://eventstore.com/projection/{name}/query” to update our projection definition code in production. Do you see any problems with this? If so, do you have other recommendations on how to update the definition?
  • Will any updates to the projection cause the input events to be replayed? We see that there are checkpoint streams that exist (e.g. the $projections-{projection_name}-{input_stream_name}-checkpoint streams), but we weren’t really sure how these checkpoints work. We plan to have millions of events going into this projection in production, so we would like to avoid situations where we end up replaying all of these events.

Please let us know if there’s anything unclear, thanks so much!