Pulling all events from the event store can become costly over time, because the number of events can explode.
To speed up the initialization of a new microservice, you should create snapshots of your application state, from time to time (and store it in some fast-access memory / cache). All the events that are stored after a snapshot, are based on the application state from the snapshot.
In that way, when you deploy a new microservice, it will first load the most recent snapshot, and then apply all the events that were stored after that snapshot, to get up to date with the app state.
You can adjust the frequency on which the snapshots are being made, so that the number of extra-events that need to be loaded, is relatively small.
This is a nice article that you can check out for more details.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…