+ All Categories
Home > Documents > Microser vices

Microser vices

Date post: 02-Jan-2022
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
53
Microservices Microservices 1
Transcript
Page 1: Microser vices

MicroservicesMicroservices

1

Page 2: Microser vices
Page 3: Microser vices

V2 - Latest Releases ofSpring BootSpring CloudDocker andKubernetesSkip to Next Section :)

V1 - Old VersionsSpring Boot v2.3 and LOWERContinue on to next lecture :(

Microservices - V2Microservices - V2

2

Page 4: Microser vices

You have skipped V1Go to next lecture!

You have completed V1Option 1: Start from Zero Again:

Go to the next lecture!Option 2: Get a Quick Start:

Jump to "Step 21 - QuickStart by ImportingMicroservices"

Same microservices as V1: Currency Exchange andCurrency ConversionVery little changes in Eureka Naming ServerStep 21 helps you set these up and get started quickly!

Microservices - V2Microservices - V2

3

Page 5: Microser vices

Microservices Evolve QuicklyImportant Updates:

Latest Versions of Spring Boot & SpringCloud

Spring Cloud LoadBalancer instead of RibbonSpring Cloud Gateway instead of ZuulResilience4j instead of Hystrix

Docker: Containerize MicroservicesRun microservices using Docker and DockerCompose

Kubernetes: Orchestrate all yourMicroservices with Kubernetes

Microservices - V2 - What's NewMicroservices - V2 - What's New

4

Page 6: Microser vices

MonolithMonolith5

Page 7: Microser vices

MicroservicesMicroservices

6

Page 8: Microser vices

What is a Microservice?What is a Microservice?

Small autonomous services that work together

Sam Newman

7

Page 9: Microser vices

What is a Microservice?What is a Microservice?

Approach to developing a application as a suite of small services, each running in its own process and communicating with lightweight

mechanisms o�en an HTTP resource API. These services are built around business capabilities and

independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services,

which may be written in different programming languages and usedifferent data storage technologies.

James Lewis and Martin Fowler

8

Page 10: Microser vices

RESTSmall Well Chosen DeployableUnitsCloud Enabled

Microservices for meMicroservices for me

9

Page 11: Microser vices

Microservices - ChallengesMicroservices - Challenges

Bounded ContextConfiguration ManagementDynamic Scale Up and Scale DownVisibilityPack of CardsZero Downtime Deployments

10

Page 12: Microser vices

Microservice - SolutionsMicroservice - Solutions

Spring Cloud Umbrella ProjectsCentralized Configuration Management (Spring Cloud Config Server)Location Transparency - Naming Server (Eureka)Load Distribution (Ribbon, Spring Cloud Load Balancer)Visibility and Monitoring (Zipkin)API Gateway (Zuul, Spring Cloud Gateway)Fault Tolerance (Hystrix, Resilience4j)

Docker: Language Neutral, Cloud Neutral deployable unitsKubernetes: Orchestrate Thousands of Microservices

11

Page 13: Microser vices

Microservices - 3 Key AdvantagesMicroservices - 3 Key Advantages

New Technology & Process AdoptionDynamic ScalingFaster Release Cycles

12

Page 14: Microser vices

Ports StandardizationPorts StandardizationApplication Port

Limits Microservice 8080, 8081, ...

Spring Cloud Config Server 8888

Currency Exchange Microservice 8000, 8001, 8002, ..

Currency Conversion Microservice 8100, 8101, 8102, ...

Netflix Eureka Naming Server 8761

API Gateway 8765

Zipkin Distributed Tracing Server 9411

13

Page 15: Microser vices

Lot of configuration:External ServicesDatabaseQueueTypical Application Configuration

Configuration variations:1000s of MicroservicesMultiple EnvironmentsMultiple instances in each Environment

How do you manage all thisconfiguration?

Need for Centralized ConfigurationNeed for Centralized Configuration

14

Page 16: Microser vices

Config ServerConfig Server15

Page 17: Microser vices

EnvironmentsEnvironments16

Page 18: Microser vices

EnvironmentsEnvironments

17

Page 19: Microser vices

EnvironmentsEnvironments

18

Page 20: Microser vices

Microservices OverviewMicroservices Overview

19

Page 21: Microser vices

Currency Exchange MicroserviceCurrency Exchange Microservice

What is the exchange rate of one currency in another?

http://localhost:8000/currency-exchange/from/USD/to/INR

{ "id":10001, "from":"USD", "to":"INR", "conversionMultiple":65.00, "environment":"8000 instance-id" }

20

Page 22: Microser vices

Currency Conversion MicroserviceCurrency Conversion Microservice

Convert 10 USD into INR

http://localhost:8100/currency-conversion/from/USD/to/INR/quantity/10

{ "id": 10001, "from": "USD", "to": "INR", "conversionMultiple": 65.00, "quantity": 10, "totalCalculatedAmount": 650.00, "environment": "8000 instance-id" }

21

Page 23: Microser vices

Naming ServerNaming Server

22

Page 24: Microser vices

Load BalancingLoad Balancing

23

Page 25: Microser vices

From

Simple, yet effective way to route to APIsProvide cross cutting concerns:

SecurityMonitoring/metrics

Built on top of Spring WebFlux (ReactiveApproach)Features:

Match routes on any request attributeDefine Predicates and FiltersIntegrates with Spring Cloud Discovery Client (LoadBalancing)Path Rewriting

Spring Cloud GatewaySpring Cloud Gateway

https://docs.spring.io

24

Page 26: Microser vices

Circuit BreakerCircuit Breaker

What if one of the services is down or is slow?Impacts entire chain!

Questions:Can we return a fallback response if a service is down?Can we implement a Circuit Breaker pattern to reduce load?Can we retry requests in case of temporary failures?Can we implement rate limiting?

Solution: Circuit Breaker Framework - Resilience4j

25

Page 27: Microser vices

Distributed TracingDistributed Tracing

Complex call chainHow do you debug problems?How do you trace requests across microservices?Enter Distributed Tracing

26

Page 28: Microser vices

Distributed TracingDistributed Tracing

27

Page 29: Microser vices

Distributed Tracing - AsynchronousDistributed Tracing - Asynchronous28

Page 30: Microser vices

MicroservicesMicroservices

Enterprises are heading towards microservices architecturesBuild small focused microservicesFlexibility to innovate and build applications in different programming languages (Go, Java,Python, JavaScript, etc)BUT deployments become complex!How can we have one way of deploying Go, Java, Python or JavaScript .. microservices?

Enter containers!

29

Page 31: Microser vices

Create Docker images for eachmicroserviceDocker image contains everything amicroservice needs to run:

Application Runtime (JDK or Python orNodeJS)Application codeDependencies

You can run these docker containersthe same way on any infrastructure

Your local machineCorporate data centerCloud

DockerDocker

30

Page 32: Microser vices

Traditional Deployment

31

Page 33: Microser vices

Deployments using Virtual Machines

32

Page 34: Microser vices

Deployments using Docker

33

Page 35: Microser vices

Docker Architecture

34

Page 36: Microser vices

Requirement : I want 10 instances ofMicroservice A container, 15 instancesof Microservice B container and ....Typical Features:

Auto Scaling - Scale containers based ondemandService Discovery - Help microservices findone anotherLoad Balancer - Distribute load amongmultiple instances of a microserviceSelf Healing - Do health checks and replacefailing instancesZero Downtime Deployments - Release newversions without downtime

Container OrchestrationContainer Orchestration

35

Page 37: Microser vices

AWS SpecificAWS Elastic Container Service (ECS)AWS Fargate : Serverless version of AWS ECS

Cloud Neutral - KubernetesAWS - Elastic Kubernetes Service (EKS)Azure - Azure Kubernetes Service (AKS)GCP - Google Kubernetes Engine (GKE)EKS/AKS does not have a free tier!

We use GCP and GKE!

Container Orchestration OptionsContainer Orchestration Options

36

Page 38: Microser vices
Page 39: Microser vices

Kubernetes Architecture

37

Page 40: Microser vices

Kubernetes Architecture

38

Page 41: Microser vices

Kubernetes Architecture

39

Page 42: Microser vices

Kubernetes Architecture

40

Page 43: Microser vices

Kubernete Deployments

41

Page 44: Microser vices

Kubernete Deployments

42

Page 45: Microser vices

Kubernete Deployments

43

Page 46: Microser vices

Kubernete Service

44

Page 47: Microser vices

Kubernetes - Liveness and Readiness ProbesKubernetes - Liveness and Readiness Probes

Kubernetes uses probes to check the health of a microservice:If readiness probe is not successful, no traffic is sentIf liveness probe is not successful, pod is restarted

Spring Boot Actuator (>=2.3) provides inbuilt readiness and liveness probes:/health/readiness/health/liveness

45

Page 48: Microser vices

What Next?What Next?

46

Page 49: Microser vices

Docker & Kubernetes in DepthDocker & Kubernetes in Depth

47

Page 52: Microser vices

ServerlessServerless

50

Page 53: Microser vices

Recommended