About me Seasoned Enterprise/Solution/Technical Architect. R esponsible for providing solutions , proposals and technical leadership. C onsulted various organizations on Microservices and applied patterns like CQRS, Event Sourcing etc. Founder of www.javaarchitectforum.com
Agenda Event Sourcing and CQRS are modern and very popular architecure patterns to E nsure scalablity, security and robustness. Problem Context W h at is Event Sourcing What is CQRS Solving Problem Context with Event Sourcing and CQRS Technology Choices Addiotnal Notes
Problem Context #1 Client IO Intensive back-end 1 2 Client Non Blocking Adapter 1 2 IO Intensive back-end How to decouple a blocking backend and make a non-blocking system ?
Problem Context #2 How to implement a distributed transcation across microservice ? MS 1 MS 2 Client 1 2 3 4
Problem Context #3 How to scale a CRUD massively? Client Domain Micro service RDBMS Create READ Update Delete Update operations are heavy and use locking. Handling concurrency may impact performance No Audit log. Cant make a UNDO.
Event Sourcing | Pattern Event Sourcing is an approach Every change in the application state is captured by a Event. L og all such events in DB ( Event Store) in a sequence. Event Store would be a append only data structure. Client Domain Micro service Event Id Event Name State 1 Employee Added Employee{ id=1,Name=John ,,,,} 2 Employee Updated Employee{ id=1,Name=John ,,,,} Event Store
CQRS | Pattern Command(Write) Query(Read) Responsibility Segregation Separate Read and Write Model – Different read and write Stores May be different API ( Microservices ) for Command( Write) and Query (Read) Client Read service Command Service Read DB Write DB Sync Read DB with Write DB using different mechanisms like events etc.
Applying Event Sourcing | PC #1 How to decouple a blocking backend and make a non-blocking system ? Applying Event Sourcing Client IO Intensive back-end 1 2 Client 1 2 IO Intensive back-end Wrapper/ Adapter Service Event Bus Event DB Event Listener API
Applying Event Sourcing & CQRS | PC #3 How to scale CRUD massively. Applying Event Sourcing and CQRS Client Write Microservice Event Bus Event DB API Client Microservice Database Read API Event Handler Read DB Event Store Read Write