leaving the monolith thanks to #eventsourcing @ #scpna

37
Leaving The Monolith thanks to Event Sourcing Migrations, Event Sourcing, AWS, and other things of the meter @JavierCane #scpna - Software Craftsmanship Pamplona

Upload: javier-ferrer-gonzalez

Post on 13-Apr-2017

1.498 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Leaving The Monolith thanks to #EventSourcing @ #scpna

Leaving The Monolith thanks to Event SourcingMigrations, Event Sourcing, AWS, and other things of the meter

@JavierCane#scpna - Software Craftsmanship Pamplona

Page 2: Leaving The Monolith thanks to #EventSourcing @ #scpna

@JavierCane#scpna - Software Craftsmanship Pamplona

Saliendo del monolito, al Rico EventitoMigraciones, Event Sourcing, y otras cosas del meter

Page 3: Leaving The Monolith thanks to #EventSourcing @ #scpna

Welcome!I’m Javier Ferrer González

@JavierCane

Page 4: Leaving The Monolith thanks to #EventSourcing @ #scpna

Greetings to Sergi!@SergiGP

Welcome!

Page 5: Leaving The Monolith thanks to #EventSourcing @ #scpna

Contents

! Starting point ! Needs ! Action plan ! Flow example ! Conclusions

Page 6: Leaving The Monolith thanks to #EventSourcing @ #scpna

1. Starting point

Context

Page 7: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 8: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 9: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 10: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 11: Leaving The Monolith thanks to #EventSourcing @ #scpna

Starting point Context

! Mobile first application ! Crazy growth (ads in TV in USA and Turkey)

◕ External services (Parse, Kahuna…)

◕ In-house API ! Where do we go

◕ Microservices architecture

◕ Event Sourcing

◕ Orchestration Layer

Page 12: Leaving The Monolith thanks to #EventSourcing @ #scpna

2. Needs

New chat system!

Page 13: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 14: Leaving The Monolith thanks to #EventSourcing @ #scpna

Needs New chat system!

! From:

◕ REST API

◕ “Chat” (messaging system) ! To:

◕ WebSockets (better UX)

◕ Chat

◕ Isolated from API service

◕ Backwards Compatible (mobile!)

◕ Scale!

Page 15: Leaving The Monolith thanks to #EventSourcing @ #scpna

3. Action plan

Maintaining Backwards Compatibility (BC)

Page 16: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

! Develop new chat with Scala and Akka, and WS ! Maintain BC taking advantage of Event Sourcing

Page 17: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

Page 18: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

Page 19: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

! Why not sync through DB?

◕ Share DB: K.A.O.S.

◕ Doesn’t scale

◕ Coupling

Page 20: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

Page 21: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

! Why not sync through SQS?

◕ Doesn’t scale

Page 22: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

Page 23: Leaving The Monolith thanks to #EventSourcing @ #scpna

Action plan Maintaining BC

! Why?

◕ Scale

◕ Decoupled

◕ Open-Closed Principle compliant at a services level

Page 24: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 25: Leaving The Monolith thanks to #EventSourcing @ #scpna
Page 26: Leaving The Monolith thanks to #EventSourcing @ #scpna

4. Flow example

Maintaining BC

Page 27: Leaving The Monolith thanks to #EventSourcing @ #scpna

From the new chat to the legacy one

Page 28: Leaving The Monolith thanks to #EventSourcing @ #scpna

Flow example Maintaining BC

Page 29: Leaving The Monolith thanks to #EventSourcing @ #scpna

From the legacy chat to the new one

Page 30: Leaving The Monolith thanks to #EventSourcing @ #scpna

Flow example Maintaining BC

Page 31: Leaving The Monolith thanks to #EventSourcing @ #scpna

5. Conclusions

Page 32: Leaving The Monolith thanks to #EventSourcing @ #scpna

Conclusions

! Event Sourcing ~~ DIP at a services level

◕ Dependency Inversion Principle (CodelyTV video)

◕ Allow OCP: One SNS publishes to many SQS

◕ Encourage SRP

◕ Decoupleeeeee

Page 33: Leaving The Monolith thanks to #EventSourcing @ #scpna

Conclusions

Page 34: Leaving The Monolith thanks to #EventSourcing @ #scpna

Conclusions

! Isolated services

◕ Different technologies

◕ Different context

◕ Change context => Mental challenge ! AWS vs RabbitMQ

◕ Go fast => AWS

! From PHP to Scala: 🙃 🙂 🙃 💃 🙃 😀 😐 😳 🤔 🙂 🙃 🙂 …

! Know more at #SCBCN16! (October 1st & 2nd in BCN)

Page 35: Leaving The Monolith thanks to #EventSourcing @ #scpna

References / To take away

! A Series of Fortunate Events ! The anatomy of Domain Event ! 6 Code Smells with your CQRS Events and How to

Avoid Them ! json:api standard ! Sending Amazon SNS Messages to Amazon SQS

Queues ! Subscribing a Queue to an Amazon SNS Topic

Page 36: Leaving The Monolith thanks to #EventSourcing @ #scpna

Questions?

Thanks!Contact @JavierCane || @SergiGP [email protected] Codely.TV

Page 37: Leaving The Monolith thanks to #EventSourcing @ #scpna

Credits

! Presentation base template by SlidesCarnival ! Graphics generated using draw.io