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

Designing cloud-native microservices using patterns

Designing cloud-native microservices using patterns

Designing cloud-native microservices using patterns
Felix Coutinho
Cloud-native applications are a collection of small, independent, and loosely coupled services. How can you as a developer or an architect design microservices that comply with this definition? And more, how can you do this using industry-level design patterns such as fanout, mat-view, observability, CQRS?

The intent of this talk is to give real-world examples and feed the participants with confidence that cloud-native microservices are possible to implement since you design them properly.

8ad6e0021df0a67faac106fafd918365?s=128

Felix Coutinho

June 09, 2021
Tweet

Transcript

  1. Designing cloud-native microservices using patterns By Jeremy Perkins From Unsplash

  2. Who am I? Felix Coutinho @ CI&T Canada https://twitter.com/felixcoutinho https://www.linkedin.com/in/felixcoutinho/

  3. None
  4. Design Patterns

  5. Design patterns “A design pattern is a general repeatable solution

    to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.” - Alexander Shvets on Dive into Design Patterns
  6. Design patterns The problem “An intersection between two roads is

    causing issues. People are getting injured and traffic is getting slow.”
  7. A traffic light By Jean Carlo Emer From Unsplash The

    Solution #1
  8. A roundabout By Lucas Miguel From Unsplash The Solution #2

  9. Design patterns “A design pattern isn't a finished design that

    can be transformed directly into code” - Alexander Shvets on Dive into Design Patterns You need to identify the problem, understand the scenario and choose the best solution
  10. You need to design By Scott Graham from Unplash

  11. Cloud Native

  12. Cloud Native Definition “Cloud-native applications are a collection of small,

    independent, and loosely coupled services.” https://www.redhat.com/en/topics/cloud-native-apps * Small * Independent * Loosely Coupled
  13. “Cloud Native Is about Culture, Not Containers” Holly Cummins Innovation

    Leader, IBM
  14. Microservices Design Patterns

  15. Decomposition

  16. Problem How to decompose an application into services?

  17. Decompose by subdomain * Small * Loosely Coupled Solution Define

    services corresponding to Domain-Driven Design (DDD) subdomains.
  18. Source Łukasz. 2018. "The nature of Domain Driven Design -

    what the heck is it?" Braintelligence, Accessed on May 2021
  19. Data management

  20. Problem What’s the database architecture in a microservices application?

  21. Database per service * Loosely Coupled Solution Keep each microservice’s

    persistent data private to that service and accessible only via its API.
  22. None
  23. A service’s transactions only involve its database.

  24. Problem How to implement a query that retrieves data from

    multiple services in a microservice architecture?
  25. (CQRS) Command Query Responsibility Segregation * Independent Solution Define a

    view database, which is a read-only replica that is designed to support that query. The application keeps the replica up to data by subscribing to Domain events published by the service that own the data.
  26. Source https://microservices.io/patterns/data/cqrs.html Accessed on May 2021

  27. Code Duplication Eventual Consistency

  28. Problem How to query data from different services without couple

    the services?
  29. Materialized Views * Independent * Loosely Coupled Solution Generate, in

    advance, a view that materializes the data in a format suited to the required results set
  30. None
  31. Eventual Consistency

  32. Problem How to reliably/atomically update the database and publish messages/events?

  33. Event sourcing / Fan-out * Independent * Loosely Coupled Solution

    Whenever the state of a business entity changes, a new event is appended to the list of events. When a service saves an event in the event store, it is delivered to all interested subscribers.
  34. None
  35. Eventual Consistency

  36. Observability

  37. Problem How to understand the behavior of several application instances

    and troubleshoot the problems?
  38. None
  39. Distributed tracing * Independent Solution Assigns each external request a

    unique id and includes this id in all log messages associated.
  40. Source https://lightstep.com/distributed-tracing/ Accessed on May 2021

  41. It costs a lot of money

  42. Security

  43. Problem How to communicate the identity of the requestor to

    the services that handle the request?
  44. Access Token * Independent * Loosely Coupled Solution User a

    access token (possible JWT) that securely identifies the requestor in each request to the services.
  45. That’s all folks

  46. Quer dar um upgrade no seu setup? A CI&T te

    ajuda! Participe do nosso sorteio e concorra a R$2.000,00 em créditos para equipar o seu home office. Inscreva-se no formulário do estande CI&T.
  47. Who am I? Felix Coutinho @ CI&T Canada https://twitter.com/felixcoutinho https://www.linkedin.com/in/felixcoutinho/

  48. References Books Dive into Design Patterns - Alexander Shvets Microservices

    patterns - Chris Richardson Domain-Driven Design - Eric Evans Designing Distributed Systems - Brendan Burns Monolith to Microservices - Sam Newman Building Microservices - Sam Newman Beyond the Twelve-Factor App - Kevin Hoffman Patterns, Principles, and Practices of Domain-Driven Design - Scott Millett, Nick Tune Cloud Design Patterns - Alex Homer, John Sharp, Larry Brader, Masashi Narumoto, Trent Swanson Building Event-Driven Microservices - Adam Bellemare Links https://github.com/cncf/toc/blob/main/DEFINITION.md https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/definition https://www.redhat.com/en/topics/cloud-native-apps https://microservices.io/index.html
  49. Bonus!

  50. Problem How do you migrate a legacy monolithic application to

    a microservice architecture?
  51. Strangler application Solution Incrementally developing a new (strangler) application around

    the legacy application.
  52. Source https://microservices.io/patterns/refactoring/strangler-application.html Accessed May 2021