Businesses must innovate at a much faster rate to stay ahead of the competition. They must significantly improve how they develop and deploy the software that is the foundation for innovation.
Not only must businesses adopt agile practices and deploy on the cloud but they must also replace their large, cumbersome monolithic applications with microservices.
When developing microservices you must tackle the problem of distributed data management. Each microservice has its own private database, sometimes a SQL and sometimes a NoSQL database.
Developing business transactions that update entities that are owned by multiple services is a challenge, as is implementing queries that retrieve data from multiple services.
For most applications, the way to make microservices work and to manage distributed data successfully is to adopt an event-driven architecture. In an event-driven architecture, a service publishes events when something notable happens, such as when it updates a business object. Other services subscribe to those events. In response to an event a service typically updates its own state. It might also publish more events, which then get consumed by other services.
You can use an event-driven approach to implement eventually consistent transactions and to maintaining materialized views.
You can use events to implement eventually consistent business transactions that span multiple services. ACID transactions are replaced by multi-step, event-driven eventually consistent workflows. At each step, a service updates its data and then publishes an event that triggers the next step.
You can also use events to maintain one or more materialized views. Each view is optimized for a particular set of queries. The service that maintains the view does so by subscribing to events that are published when the system of record is updated.
As you can see, an event-driven architecture solves the distributed data management problems inherent in a microservice architecture. However, implementing an event-driven architecture is not easy. To learn about the challenges and how to solve them, read on: read on