Download - Microser vices
![Page 1: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/1.jpg)
MicroservicesMicroservices
1
![Page 2: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/2.jpg)
![Page 3: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/3.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/4.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/5.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/6.jpg)
MonolithMonolith5
![Page 7: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/7.jpg)
MicroservicesMicroservices
6
![Page 8: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/8.jpg)
What is a Microservice?What is a Microservice?
Small autonomous services that work together
Sam Newman
7
![Page 9: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/9.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/10.jpg)
RESTSmall Well Chosen DeployableUnitsCloud Enabled
Microservices for meMicroservices for me
9
![Page 11: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/11.jpg)
Microservices - ChallengesMicroservices - Challenges
Bounded ContextConfiguration ManagementDynamic Scale Up and Scale DownVisibilityPack of CardsZero Downtime Deployments
10
![Page 12: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/12.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/13.jpg)
Microservices - 3 Key AdvantagesMicroservices - 3 Key Advantages
New Technology & Process AdoptionDynamic ScalingFaster Release Cycles
12
![Page 14: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/14.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/15.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/16.jpg)
Config ServerConfig Server15
![Page 17: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/17.jpg)
EnvironmentsEnvironments16
![Page 18: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/18.jpg)
EnvironmentsEnvironments
17
![Page 19: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/19.jpg)
EnvironmentsEnvironments
18
![Page 20: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/20.jpg)
Microservices OverviewMicroservices Overview
19
![Page 21: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/21.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/22.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/23.jpg)
Naming ServerNaming Server
22
![Page 24: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/24.jpg)
Load BalancingLoad Balancing
23
![Page 25: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/25.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/26.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/27.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/28.jpg)
Distributed TracingDistributed Tracing
27
![Page 29: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/29.jpg)
Distributed Tracing - AsynchronousDistributed Tracing - Asynchronous28
![Page 30: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/30.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/31.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/32.jpg)
Traditional Deployment
31
![Page 33: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/33.jpg)
Deployments using Virtual Machines
32
![Page 34: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/34.jpg)
Deployments using Docker
33
![Page 35: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/35.jpg)
Docker Architecture
34
![Page 36: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/36.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/37.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/38.jpg)
![Page 39: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/39.jpg)
Kubernetes Architecture
37
![Page 40: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/40.jpg)
Kubernetes Architecture
38
![Page 41: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/41.jpg)
Kubernetes Architecture
39
![Page 42: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/42.jpg)
Kubernetes Architecture
40
![Page 43: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/43.jpg)
Kubernete Deployments
41
![Page 44: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/44.jpg)
Kubernete Deployments
42
![Page 45: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/45.jpg)
Kubernete Deployments
43
![Page 46: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/46.jpg)
Kubernete Service
44
![Page 47: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/47.jpg)
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](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/48.jpg)
What Next?What Next?
46
![Page 49: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/49.jpg)
Docker & Kubernetes in DepthDocker & Kubernetes in Depth
47
![Page 50: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/50.jpg)
Full StackFull Stack
48
![Page 51: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/51.jpg)
AWS CertificationsAWS Certifications
49
![Page 53: Microser vices](https://reader030.vdocument.in/reader030/viewer/2022013018/61d12ce868a2ba1cc107ec3b/html5/thumbnails/53.jpg)