Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Design Patterns

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Design patterns The problem “An intersection between two roads is causing issues. People are getting injured and traffic is getting slow.”

Slide 7

Slide 7 text

A traffic light By Jean Carlo Emer From Unsplash The Solution #1

Slide 8

Slide 8 text

A roundabout By Lucas Miguel From Unsplash The Solution #2

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

You need to design By Scott Graham from Unplash

Slide 11

Slide 11 text

Cloud Native

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

“Cloud Native Is about Culture, Not Containers” Holly Cummins Innovation Leader, IBM

Slide 14

Slide 14 text

Microservices Design Patterns

Slide 15

Slide 15 text

Decomposition

Slide 16

Slide 16 text

Problem How to decompose an application into services?

Slide 17

Slide 17 text

Decompose by subdomain * Small * Loosely Coupled Solution Define services corresponding to Domain-Driven Design (DDD) subdomains.

Slide 18

Slide 18 text

Source Łukasz. 2018. "The nature of Domain Driven Design - what the heck is it?" Braintelligence, Accessed on May 2021

Slide 19

Slide 19 text

Data management

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Database per service * Loosely Coupled Solution Keep each microservice’s persistent data private to that service and accessible only via its API.

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

A service’s transactions only involve its database.

Slide 24

Slide 24 text

Problem How to implement a query that retrieves data from multiple services in a microservice architecture?

Slide 25

Slide 25 text

(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.

Slide 26

Slide 26 text

Source https://microservices.io/patterns/data/cqrs.html Accessed on May 2021

Slide 27

Slide 27 text

Code Duplication Eventual Consistency

Slide 28

Slide 28 text

Problem How to query data from different services without couple the services?

Slide 29

Slide 29 text

Materialized Views * Independent * Loosely Coupled Solution Generate, in advance, a view that materializes the data in a format suited to the required results set

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Eventual Consistency

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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.

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Eventual Consistency

Slide 36

Slide 36 text

Observability

Slide 37

Slide 37 text

Problem How to understand the behavior of several application instances and troubleshoot the problems?

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Distributed tracing * Independent Solution Assigns each external request a unique id and includes this id in all log messages associated.

Slide 40

Slide 40 text

Source https://lightstep.com/distributed-tracing/ Accessed on May 2021

Slide 41

Slide 41 text

It costs a lot of money

Slide 42

Slide 42 text

Security

Slide 43

Slide 43 text

Problem How to communicate the identity of the requestor to the services that handle the request?

Slide 44

Slide 44 text

Access Token * Independent * Loosely Coupled Solution User a access token (possible JWT) that securely identifies the requestor in each request to the services.

Slide 45

Slide 45 text

That’s all folks

Slide 46

Slide 46 text

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.

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

Bonus!

Slide 50

Slide 50 text

Problem How do you migrate a legacy monolithic application to a microservice architecture?

Slide 51

Slide 51 text

Strangler application Solution Incrementally developing a new (strangler) application around the legacy application.

Slide 52

Slide 52 text

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