26
EVENT SOURCING Cristian Iliescu ( ) [email protected]

Event Sourcing

Embed Size (px)

Citation preview

EVENT SOURCINGCristian Iliescu ( )[email protected]

“We are the sum total of our experiences. Those experiences– be they positive or negative – make us the person we are,

at any given point in our lives. And, like a flowing river, thosesame experiences, and those yet to come, continue to

influence and reshape the person we are, and the person webecome. None of us are the same as we were yesterday, nor

will be tomorrow.”

WHAT IS AN EVENT?

An event is a notable thingIt happened in the past => is immutableInvolves one “producer” and one or many “consumers”

LET'S CHANGE THEPERSPECTIVE

ACCOUNT EXAMPLEOpen an accountReceive some moneyMake a paymentCheck balanceMake another payment

MYSQL APPROACHAction MySQL action

Action MySQL action

create account table Create

create account Insert

receive money Read + Update

make payment Read + Update

check balance Read

make payment Read + Update

ES APPROACHAction NoSQL action

Action NoSQL action

create account Create

receive money Create

make payment Create

check balance Read

make payment Create

EVENT SOURCINGPRINCIPLES

Representing objects as a sequence of eventsNever modify, always go forward

CRUD => CR

HOW IT WORKS ?

Captures every change of the application in an eventOrganises all the events in orderCombines all events in the right order to obtain the statefrom a specific moment

WHY EVENTSOURCING?

Storage IgnoranceFlexibilityImproved performanceSimplify Developer's Life

STORAGE IGNORANCE & FLEXIBILITYAll data are stored as eventsNo more tables and complex relationshipsSave and execute

IMPROVED PERFORMANCEEvents can be published as soon as they happenNo blocking operationsEvents can be processed in parallelEvents can be multiplexed to multiple subscribersKeep read models directly in memory

SIMPLIFY DEVELOPER'S LIFESimplifies deployment and maintenanceNo data is ever lostReduces expenses on both the hardware and so wareFits very well with new technologies: Cloud Computing,Big Data processing

OPTIMIZATION

OBJECTS WITH COMPLEX LIFETIMES

CQRS

DOWNSIDES

Extra storage costsFew frameworks to support event sourcingLack of information and guidance

CONCLUSIONS

Event Sourcing doesn't lose information=> it offers the possibility to create a wide variety ofreportsCompatible with non relational database

Q&A