Architecting Cloud Native Applications
上QQ阅读APP看书,第一时间看更新

Solution

Segregate upstream producer (that is, command) components from downstream consumer (that is, query) components by eliminating all synchronous inter-component communication. Originate data in upstream components, which typically apply the Database-First variant of the Event Sourcing pattern to atomically deliver events to the stream. This enables an upstream component to easily query its own table for the current state.

Downstream components consume the events and maintain their own materialized views that are optimized for each component's specific needs. Each component employs polyglot persistence and chooses the appropriate cloud-native database type for each view. A downstream component is then free to perform natural, synchronous intra-component queries against its own materialized views.