Bird
0
0

You want to rebuild the current state from a Kafka topic storing events using event sourcing. Which approach is best to handle a large number of events efficiently?

hard📝 Application Q15 of 15
Kafka - Event-Driven Architecture
You want to rebuild the current state from a Kafka topic storing events using event sourcing. Which approach is best to handle a large number of events efficiently?
ARead all events from the beginning every time to rebuild state
BOnly read the latest event for each entity from the topic
CUse snapshots periodically and then replay only recent events
DDelete old events from the topic to reduce size
Step-by-Step Solution
Solution:
  1. Step 1: Understand rebuilding state from events

    Replaying all events from the start is slow for large data; deleting events loses history.
  2. Step 2: Use snapshots to optimize

    Snapshots save a recent state, so only new events after snapshot need replay, improving efficiency.
  3. Final Answer:

    Use snapshots periodically and then replay only recent events -> Option C
  4. Quick Check:

    Snapshots + replay recent events = efficient rebuild [OK]
Quick Trick: Snapshots speed up rebuilding by avoiding full replay [OK]
Common Mistakes:
  • Replaying all events every time (slow)
  • Deleting events loses full history
  • Reading only latest event misses changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes