TDC2016POA | Trilha Arquitetura - CQRS e Event Driven Architecture valem a pena? Sim ou Claro?

Preview:

Citation preview

Globalcode – Open4education

CQRS and Event Driven Architecture

Andre Eberhardt

Globalcode – Open4education

whoami

/in/andreeberhardt

@aeberha

/eberhara

Software Specialist @ ADP

Globalcode – Open4education

motivation

Globalcode – Open4education

agenda

cqrswhat’s it?why does it matter?when should (or not) it be applied?

event driven architectureintrousage with cqrs

sample app...

Globalcode – Open4education

what’s cqrs?

Command

Query

Responsibility

Segregation

Globalcode – Open4education

an architectural model?

NO

Globalcode – Open4education

a pattern?

YES!

Globalcode – Open4education

it’s not this...

Globalcode – Open4education

it could be this...

Globalcode – Open4education

... or even this!

Globalcode – Open4education

so, why does it matter?

Scalability

Reduce complexity (domain level)

Flexibility

Focus on domain logic / proper technology

Task-based operations / Stale data

Globalcode – Open4education

but... and the downsides?

Learning curve / fear of change

Complexity

Eventual consistency

"Most people using CQRS (and event sourcing too) shouldn't have done so." —Udi Dahan

Globalcode – Open4education

so when should I apply it?

Decision per Bounded Context

Collaborative / complex domainsMultiple operations in parallel (stale data)

Distributed / specialized teams

Command vs Read performance

Globalcode – Open4education

and when avoid it?

Simple / static CRUD

Sequential operations

Non-collaborative bounded contexts

Eventual consistency not acceptable

Globalcode – Open4education

event driven architecture

Globalcode – Open4education

what’s that now?

State changes

Event consumers vs producers

Fire-and-forget

Happens in the past“User created”, “User deleted”, ...

Globalcode – Open4education

and why is that good?

Immutable states

Loosely coupled apps

Fits well with some rock stars (CQRS and DDD)

Async process

State reproducibility

Globalcode – Open4education

request-driven soa

Globalcode – Open4education

event driven architecture

Globalcode – Open4education

cqrs without events...

Globalcode – Open4education

cqrs and events?!

Globalcode – Open4education

lessons learned

Start small and extensible

Scale when you need to scaleAvoid huge / complex architectures for small problemsAvoid scaling when you don’t need to

Globalcode – Open4education

gurus

Greg Young

Martin Fowler

Udi Dahan

Globalcode – Open4education

sample app...

https://github.com/eberhara/sample-cqrs

Globalcode – Open4education

thank you :)

/in/andreeberhardt

@aeberha

/eberhara