migrating to microservice databases
play

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/


  1. Migrating to Microservice Databases: From Relational Monolith to Distributed Data Edson Yanaga Director of Developer Experience @yanaga

  2. Java Champion Microsoft MVP Join developers.redhat.com 2

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

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

  5. Join developers.redhat.com 5

  6. DevOps & Microservices

  7. Feedback Loop

  8. Batch Size

  9. Maintenance Window Join developers.redhat.com 9

  10. Zero Downtime

  11. Blue Green Deployments Join developers.redhat.com 11

  12. Deployment Join developers.redhat.com 12

  13. Deployment Proxy Join developers.redhat.com 13

  14. Blue Proxy Green Join developers.redhat.com 14

  15. Blue Proxy Green Join developers.redhat.com 15

  16. Blue Proxy Green Join developers.redhat.com 16

  17. Blue Proxy Green Join developers.redhat.com 17

  18. Code is easy, state is hard

  19. What about my relational database?

  20. Join developers.redhat.com 20

  21. Zero Downtime Migrations

  22. Back and Forward Compatibility

  23. Baby Steps = Smallest Possible Batch Size

  24. Too many rows = Long Locks

  25. Shard your updates

  26. ALTER TABLE customers RENAME COLUMN wrong TO correct; Join developers.redhat.com 26

  27. 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; Join developers.redhat.com 27

  28. Scenarios Add a Column Rename a Column Change Type/Format of a Column Delete a Column Join developers.redhat.com 28

  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 Join developers.redhat.com 29

  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) Join developers.redhat.com 30

  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) Join developers.redhat.com 31

  32. Delete a Column 1 DON’T 2 Stop using the read value but keep writing to the column 3 Delete the column Join developers.redhat.com 32

  33. What about referential integrity constraints?

  34. Drop them and recreate when migration is done

  35. Microservices Characteristics https://martinfowler.com/microservices/

  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 •

  37. Extracting your Microservice database

  38. One database per Microservice Join developers.redhat.com 38

  39. But I have a monolithic database! Join developers.redhat.com 39

  40. Join developers.redhat.com 40

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

  42. Consistency Models

  43. Strong Consistency Eventual Consistency

  44. CRUD & CQRS

  45. CRUD (Create, Read, Update, Delete) Join developers.redhat.com 45

  46. CQRS (Command Query Responsibility Segregation) Join developers.redhat.com 46

  47. CQRS with separate data stores Join developers.redhat.com 47

  48. CQRS & Event Sourcing

  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 Join developers.redhat.com 49

  50. Shared Tables Fastest Data Integration Strong Consistency Low cohesion and high coupling Join developers.redhat.com 50

  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 Join developers.redhat.com 51

  52. Database Materialized View Better performance Strong or Eventual Consistency One database must be reachable by the other Updatable depending on DBMS support Join developers.redhat.com 52

  53. Database Trigger Depends on DBMS Support Strong Consistency One database must be reachable by the other Join developers.redhat.com 53

  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 Join developers.redhat.com 54

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

  56. Data Virtualization Real Time Access Strong Consistency Can aggregate from multiple datasources Updatable depending on Data Virtualization Platform Join developers.redhat.com 56

  57. Join developers.redhat.com 57

  58. Event Sourcing State of data is a stream of events Eases auditing Eventual Consistency Usually combined with a Message Bus High scalability Join developers.redhat.com 58

  59. Change Data Capture Read datasource is updated through a stream of events Eventual Consistency Usually combined with a Message Bus High scalability Join developers.redhat.com 59

  60. http://debezium.io

  61. Join developers.redhat.com Feedback welcome! @yanaga

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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend