Migrating to Microservice Databases: From Relational Monolith to - - PowerPoint PPT Presentation

migrating to microservice databases
SMART_READER_LITE
LIVE PREVIEW

Migrating to Microservice Databases: From Relational Monolith to - - PowerPoint PPT Presentation

Migrating to Microservice Databases: From Relational Monolith to Distributed Data Edson Yanaga Director of Developer Experience @yanaga Java Champion Microsoft MVP Join developers.redhat.com 2 http://developers.redhat.com/promotions/


slide-1
SLIDE 1

Migrating to Microservice Databases:

From Relational Monolith to Distributed Data

Edson Yanaga Director of Developer Experience @yanaga

slide-2
SLIDE 2

Join developers.redhat.com

2

Java Champion Microsoft MVP

slide-3
SLIDE 3

http://developers.redhat.com/promotions/ migrating-to-microservice-databases

slide-4
SLIDE 4

“Now, every company is a software company” — Forbes

slide-5
SLIDE 5

Join developers.redhat.com

5
slide-6
SLIDE 6

DevOps & Microservices

slide-7
SLIDE 7

Feedback Loop

slide-8
SLIDE 8

Batch Size

slide-9
SLIDE 9

Join developers.redhat.com

9

Maintenance Window

slide-10
SLIDE 10

Zero Downtime

slide-11
SLIDE 11

Join developers.redhat.com

11

Blue Green

Deployments

slide-12
SLIDE 12

Join developers.redhat.com

12

Deployment

slide-13
SLIDE 13

Join developers.redhat.com

13

Deployment

Proxy

slide-14
SLIDE 14

Join developers.redhat.com

14

Blue

Proxy

Green

slide-15
SLIDE 15

Join developers.redhat.com

15

Blue

Proxy

Green

slide-16
SLIDE 16

Join developers.redhat.com

16

Blue

Proxy

Green

slide-17
SLIDE 17

Join developers.redhat.com

17

Blue

Proxy

Green

slide-18
SLIDE 18

Code is easy, state is hard

slide-19
SLIDE 19

What about my relational database?

slide-20
SLIDE 20

Join developers.redhat.com

20
slide-21
SLIDE 21

Zero Downtime Migrations

slide-22
SLIDE 22

Back and Forward Compatibility

slide-23
SLIDE 23

Baby Steps = Smallest Possible Batch Size

slide-24
SLIDE 24

Too many rows = Long Locks

slide-25
SLIDE 25

Shard your updates

slide-26
SLIDE 26

Join developers.redhat.com

ALTER TABLE customers RENAME COLUMN wrong TO correct;

26
slide-27
SLIDE 27

Join developers.redhat.com

ALTER TABLE customers ADD COLUMN correct VARCHAR(20); UPDATE customers SET correct = wrong WHERE id BETWEEN 1 AND 100; UPDATE customers SET correct = wrong WHERE id BETWEEN 101 AND 200; ALTER TABLE customers DELETE COLUMN wrong;

27
slide-28
SLIDE 28

Join developers.redhat.com

28

Scenarios Add a Column Rename a Column Change Type/Format of a Column Delete a Column

slide-29
SLIDE 29

Join developers.redhat.com

29

Add a Column 1 ADD COLUMN 2 Code computes the read value and writes to new column 3 Update data using shards 4 Code reads and writes from the new column

slide-30
SLIDE 30

Join developers.redhat.com

30

Rename a Column 1 ADD COLUMN 2 Code reads from the old column and writes to both 3 Copy data using small shards 4 Code reads from the new column and writes to both 5 Code reads and writes from the new column 6 Delete the old column (later)

slide-31
SLIDE 31

Join developers.redhat.com

31

Change Type/Format of a Column 1 ADD COLUMN 2 Code reads from the old column and writes to both 3 Copy data using small shards 4 Code reads from the new column and writes to both 5 Code reads and writes from the new column 6 Delete the old column (later)

slide-32
SLIDE 32

Join developers.redhat.com

32

Delete a Column 1 DON’T 2 Stop using the read value but keep writing to the column 3 Delete the column

slide-33
SLIDE 33

What about referential integrity constraints?

slide-34
SLIDE 34

Drop them and recreate when migration is done

slide-35
SLIDE 35

Microservices Characteristics

https://martinfowler.com/microservices/

slide-36
SLIDE 36
  • Componentization via Services
  • Organized around Business Capabilities
  • Products not Projects
  • Smart endpoints and dumb pipes
  • Decentralized Governance
  • Decentralized Data Management
  • Infrastructure Automation
  • Design for failure
  • Evolutionary Design
slide-37
SLIDE 37

Extracting your Microservice database

slide-38
SLIDE 38

Join developers.redhat.com

38

One database per Microservice

slide-39
SLIDE 39

Join developers.redhat.com

39

But I have a monolithic database!

slide-40
SLIDE 40

Join developers.redhat.com

40
slide-41
SLIDE 41

Splitting is not easy, but how do I integrate later?

slide-42
SLIDE 42

Consistency Models

slide-43
SLIDE 43

Strong Consistency Eventual Consistency

slide-44
SLIDE 44

CRUD & CQRS

slide-45
SLIDE 45

Join developers.redhat.com

45

CRUD (Create, Read, Update, Delete)

slide-46
SLIDE 46

Join developers.redhat.com

46

CQRS (Command Query Responsibility Segregation)

slide-47
SLIDE 47

Join developers.redhat.com

47

CQRS with separate data stores

slide-48
SLIDE 48

CQRS & Event Sourcing

slide-49
SLIDE 49

Join developers.redhat.com

49

Scenarios Shared Tables Database View Database Materialized View Mirror Table using Trigger Mirror Table using Transactional Code Mirror Table using ETL Mirror Table using Data Virtualization Event Sourcing Change Data Capture

slide-50
SLIDE 50

Join developers.redhat.com

50

Shared Tables Fastest Data Integration Strong Consistency Low cohesion and high coupling

slide-51
SLIDE 51

Join developers.redhat.com

51

Database View Easiest one to implement Largest support from DBMS vendors Possible performance issues Strong Consistency One database must be reachable by the other Updatable depending on DBMS support

slide-52
SLIDE 52

Join developers.redhat.com

52

Database Materialized View Better performance Strong or Eventual Consistency One database must be reachable by the other Updatable depending on DBMS support

slide-53
SLIDE 53

Join developers.redhat.com

53

Database Trigger Depends on DBMS Support Strong Consistency One database must be reachable by the other

slide-54
SLIDE 54

Join developers.redhat.com

54

Transactional Code Any code: usually Stored Procedures or Distributed Transactions Strong Consistency Possible cohesion/coupling issues Possible performance issues Updatable depending on how it is implemented

slide-55
SLIDE 55

Join developers.redhat.com

55

ETL Tools Lots of available tools Requires external trigger (usually time-based) Can aggregate from multiple datasources Eventual Consistency Read only integration

slide-56
SLIDE 56

Join developers.redhat.com

56

Data Virtualization Real Time Access Strong Consistency Can aggregate from multiple datasources Updatable depending on Data Virtualization Platform

slide-57
SLIDE 57

Join developers.redhat.com

57
slide-58
SLIDE 58

Join developers.redhat.com

58

Event Sourcing State of data is a stream of events Eases auditing Eventual Consistency Usually combined with a Message Bus High scalability

slide-59
SLIDE 59

Join developers.redhat.com

59

Change Data Capture Read datasource is updated through a stream of events Eventual Consistency Usually combined with a Message Bus High scalability

slide-60
SLIDE 60

http://debezium.io

slide-61
SLIDE 61

Join developers.redhat.com Feedback welcome! @yanaga

slide-62
SLIDE 62 plus.google.com/+RedHat linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHatNews

Thank you!