Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Extracting services from a monolith

Extracting services from a monolith

My talk from the SoundCloud Meetup

Jano González

October 04, 2017
Tweet

More Decks by Jano González

Other Decks in Programming

Transcript

  1. • Define authoritative sources • Compose at the edge •

    Use lifecycle events when necessary The problems Eventual consistency
  2. • Standardize RPC and async mechanisms • Provide support levels

    for different tech stacks The problems Too many stacks
  3. Identify a candidate Does this feature need many changes? Is

    this feature causing technical risk? Choose an integration approach How to integrate the extracted service? Choose a migration strategy for data How to move the data to its own storage? Extracting services The process 1 2 3
  4. Identify a candidate Does this feature need many changes? Is

    this feature causing technical risk? Choose an integration approach How to integrate the extracted service? Choose a migration strategy for data How to move the data to its own storage? Extracting services The process 1 2 3
  5. Introduce a service layer for the feature If you don’t

    have it already Add an alternate path under a feature flag Beware that in-memory joins than may be needed Switch the traffic Now the code can be cleaned up Monolith as a gateway The process 2.1 2.2 2.3
  6. Introduce a service layer for the feature If you don’t

    have it already Add an alternate path under a feature flag Beware that in-memory joins than may be needed Switch the traffic Now the code can be cleaned up Monolith as a gateway The process 2.1 2.2 2.3
  7. def public_track_likes(user, pagination) if $feature.active?(:use_likes_service, user) … else … end

    end Monolith as a gateway Add an alternate path under a feature flag
  8. Introduce a service layer for the feature If you don’t

    have it already Add an alternate path under a feature flag Beware that in-memory joins than may be needed Switch the traffic Now the code can be cleaned up Monolith as a gateway The process 2.1 2.2 2.3
  9. Introduce handlers for the paths This allows for intervention Add

    an alternate path under a feature flag This may imply invoking not only the new service Switch the traffic Now the code can be cleaned up Strangler The process 2.1 2.2 2.3
  10. Introduce handlers for the paths This allows for intervention Add

    an alternate path under a feature flag This may imply invoking not only the new service Switch the traffic Now the code can be cleaned up Strangler The process 2.1 2.2 2.3
  11. Introduce handlers for the paths This allows for intervention Add

    an alternate path under a feature flag This may imply invoking not only the new service Switch the traffic Now the code can be cleaned up Strangler The process 2.1 2.2 2.3
  12. Identify a candidate Does this feature need many changes? Is

    this feature causing technical risk? Choose an integration approach How to integrate the extracted service? Choose a migration strategy for data How to move the data to its own storage? Extracting services The process 1 2 3
  13. • Allows changing the storage engine • Adds risk to

    the migration project • I haven’t used it personally, more suitable for services extracted for feature changes. Choose a migration strategy for data New schema
  14. • Low risk migration • We usually move the reads

    slowly and then do a quick write path cut-over • We’ve chosen this approach for services extracted due to technical risk Choose a migration strategy for data Same schema
  15. • Systems that were reading directly from the DB •

    How to cut-over writes • Migrating events from the monolith to the service • Outages Extracting services Some details I omitted
  16. One feature at a time When you need it Don’t

    stop delivering! Conclusions How to break your monolith