Slide 1

Slide 1 text

Serverless Microservices with Google Cloud Run Juan Guillermo Gómez @jggomezt

Slide 2

Slide 2 text

Juan Guillermo Gómez ● Co-Leader y Co-Founder del GDG Cali. ● Founder DevHack. ● Tech Lead Wordbox ● Consultant and advisor on software architecture, cloud computing and software development. ● Experience in several languages and platforms. (C, C#, Java, NodeJS, android, GCP, Firebase). ● Google Developer Expert GCP & Firebase ● BS in System Engineering and a MS in Software Engineering. ● @jggomez

Slide 3

Slide 3 text

WHERE ARE THE SLIDES? https://speakerdeck.com/jggomez/serverless-with-cloud-run

Slide 4

Slide 4 text

FOUNDATIONS

Slide 5

Slide 5 text

Where the microservices come from? ❖ Modular Programming. ❖ POO ❖ RPC. ❖ EAI. ❖ AOP. ❖ Web Services. ❖ SOA

Slide 6

Slide 6 text

Microservices

Slide 7

Slide 7 text

Microservices

Slide 8

Slide 8 text

Microservices

Slide 9

Slide 9 text

Microservices Process

Slide 10

Slide 10 text

ANALYSIS AND DESIGN

Slide 11

Slide 11 text

Modeling Microservices ❖ Model services around the business domain. ❖ Model services around quality attributes. ❖ Model services around cost

Slide 12

Slide 12 text

Microservices Description with Open API 3 OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including: ❖ Available endpoints (/users) and operations on each endpoint (GET /users, POST /users) ❖ Operation parameters Input and output for each operation ❖ Authentication methods ❖ Contact information, license, terms of use and other information. ❖ API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines.

Slide 13

Slide 13 text

Microservices Description with Open API 3

Slide 14

Slide 14 text

Microservices Description with Open API 3

Slide 15

Slide 15 text

Microservices Design

Slide 16

Slide 16 text

Create Mockups

Slide 17

Slide 17 text

BUILD MICROSERVICES

Slide 18

Slide 18 text

How to build microservices ❖ Separation of concerns. ❖ Business Context. ❖ Clean Architecture.

Slide 19

Slide 19 text

Frameworks to build microservices

Slide 20

Slide 20 text

TEST

Slide 21

Slide 21 text

How to test microservices

Slide 22

Slide 22 text

DEPLOY

Slide 23

Slide 23 text

SERVERLESS ➢ Serverless architectures are application designs that incorporate third-party “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform. ➢ Serverless architectures may benefit from significantly reduced operational cost, complexity, and engineering lead time, at a cost of increased reliance on vendor dependencies and comparatively immature supporting services. https://martinfowler.com/articles/serverless.html

Slide 24

Slide 24 text

Cloud Run ➢ Cloud Run is a managed compute platform that automatically scales your stateless containers. Cloud Run is serverless: it abstracts away all infrastructure management, so you can focus on what matters most — building great applications. ➢ Run your containers in fully managed Cloud Run, or on Cloud Run for Anthos. Anthos supports GKE on Google Cloud, on-premises and multi-cloud environments. Cloud Run is built from Knative, ensuring that your applications are built on an open standard.

Slide 25

Slide 25 text

Cloud Run - Kubernetes

Slide 26

Slide 26 text

Cloud Run https://twitter.com/ahmetb

Slide 27

Slide 27 text

Deployment

Slide 28

Slide 28 text

Cloud Run - Deploy ❖ gcloud config set project PROJECT-ID ❖ gcloud builds submit --tag gcr.io/PROJECT-ID/accountservice ❖ gcloud beta run deploy --image gcr.io/PROJECT-ID/accountservice --platform managed

Slide 29

Slide 29 text

Cloud Run - Kubernetes

Slide 30

Slide 30 text

Cloud Run - Kubernetes

Slide 31

Slide 31 text

Cloud Run - Demo https://github.com/escueladevhack/ScalabilitySoftwareArchitecture

Slide 32

Slide 32 text

CI & CD

Slide 33

Slide 33 text

Continuous Integration & Continuous Delivery

Slide 34

Slide 34 text

Continuous Integration & Continuous Delivery

Slide 35

Slide 35 text

Continuous Integration & Continuous Delivery

Slide 36

Slide 36 text

BONUS

Slide 37

Slide 37 text

BONUS

Slide 38

Slide 38 text

Proxy

Slide 39

Slide 39 text

Call a microservice to another microservice ASYNC

Slide 40

Slide 40 text

Call a microservice to another microservice ASYNC

Slide 41

Slide 41 text

Call a microservice to another microservice SYNC

Slide 42

Slide 42 text

Caching Microservices ❖ Use a memory repository for instance REDIS. ❖ Keep the data in the cache when it doesn’t change. ❖ if another component changes the data, the cache must be deleted. Queues can be the solution. ❖ Cloud run doesn’t support memory store but the cloud functions support memory store

Slide 43

Slide 43 text

Security in the Microservices ❖ Consider implementing authentication at API Gateway level with widely-used API security standards such as OAuth2 and OpenID Connect. ❖ Create a API secret for app. ❖ Security channels ❖ JWT http://kasunpanorama.blogspot.com/2015/11/microservices-in-practice.html

Slide 44

Slide 44 text

Best Practices Microservices ❖ Domain Driven Design. ❖ Decentralized Data Management ❖ Smart Endpoints and dump pipes ❖ Asynchronous Communication ❖ Avoid Coupling between Services ❖ Decentralize Development ❖ Monitoring Microservices

Slide 45

Slide 45 text

Best Practices Microservices ❖ Keep domain knowledge out of the gateway ❖ Token-based Authentication ❖ Event Driven Nature ❖ Fault Tolerance. (circuit-breaking, bulkhead, retries, timeouts, fail fast, failover caching, rate limiters, load shedders) ❖ Product Engineering

Slide 46

Slide 46 text

REFERENCES ❖ Building Microservices. Book. Sam Newman ❖ https://martinfowler.com/articles/microservices.html ❖ https://martinfowler.com/articles/serverless.html ❖ https://cloud.google.com/run/ ❖ https://medium.com/weareservian/3-best-features-of-google-cloud-run-546e367242ea ❖ https://medium.com/platform-engineer/microservices-design-guide-eca0b799a7e8 ❖ https://blog.risingstack.com/designing-microservices-architecture-for-failure/ ❖ http://kasunpanorama.blogspot.com/2015/11/microservices-in-practice.html

Slide 47

Slide 47 text

GRACIAS !! @jggomezt