Advance Microservice Patterns - Event Souring , CQRS

MohitMittal9 100 views 10 slides Feb 21, 2019
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Learn Advance Microservice Patterns - Event Sourcing, CQRS


Slide Content

Event Sourcing & CQRS By Mohit Kumar Mittal

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