What is event sourcing in microservices?

Answer

Event sourcing stores the state of an entity as an ordered sequence of events rather than as a current snapshot. Instead of a row in a database that gets overwritten with UPDATE, you append an event like OrderPlaced, OrderShipped, OrderCancelled to an append-only event log. The current state is derived by replaying all events. Benefits include a complete audit trail, the ability to replay events to rebuild state or create new projections, and natural integration with event-driven architectures. The challenges are that querying the current state requires projection maintenance, the event schema must be carefully versioned, and the event log can grow very large over time requiring snapshotting strategies.