SlideShare uma empresa Scribd logo
1 de 20
Presented by - Ashish Gautam
Spring Boot Microservices
Agenda
● Introduction
● Comparison with monolith architecture
● Advantages of microservices
● Challenges with microservices
● Eureka server
● Creating a spring boot microservice
● Communicating with other microservices
● Load balancing
Introduction
Microservices is an approach to developing a single application as a suite of small
services, each running in its own process and communicating with lightweight
mechanisms, often an HTTP resource API.
Microservices allow large systems to be built up from a number of collaborating
components. It does at the process level what Spring has always done at the
component level: loosely coupled processes instead of loosely coupled
components.
In comparison with Monolith application
Monolith applications are typically huge - more 100,000 line of code. In
some instances even more than million lines of code. Monoliths are
characterized by -
● Large Application Size
● Long Release Cycles
● Large Teams
Typical challenges in Monolith application
● Scalability challenges
● New technology adoption
● Difficult to perform automation tests
● Difficult to adapt to modern development practices
● Adapting to device explosion
Microservice architectures evolved as a solution to the scalability and
innovation challenges with monolithic architectures.
What Does Microservice Architecture Look Like?
This is how the same application would look like when developed using
microservices architecture.
Microservice architectures involve a number of small, well-designed
components interacting with messages.
Advantages of Microservices
● New technology and process adaptation becomes easier. You can try
new technologies with the newer microservices that we create.
● Faster release cycles.
● Scaling with the cloud.
● Quick setup needed: You cannot spend a month setting up each microservice.
You should be able to create microservices quickly.
● Automation: Because there are a number of smaller components instead of a
monolith, you need to automate everything - Builds, Deployment,
Monitoring, etc.
● Visibility: You now have a number of smaller components to deploy and
maintain, maybe 100 or maybe 1000 components. You should be able to
monitor and identify problems automatically. You need great visibility around
all the components.
● Configuration Management: You need to maintain configurations for
hundreds of components across environments. You would need a
Configuration Management solution
Challenges With Microservice Architectures
Spring Boot
Spring Boot enables building production-ready applications quickly and provides non-functional
features:
● Embedded servers (easy deployment with containers)
● Metrics (monitoring)
● Health checks (monitoring)
● Externalized configuration
Spring Cloud
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed
systems. Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud
developers can quickly stand up services and applications that implement those patterns.
Solutions to Challenges with Microservice Architectures
Important Spring Cloud Modules
● Dynamically scale up and down. using a combination of
○ Naming Server (Eureka)
○ Ribbon (Client Side Load Balancing)
○ Feign (Easier REST Clients)
● Visibility and monitoring with
○ Zipkin Distributed Tracing
○ Netflix API Gateway
● Configuration Management with Spring Cloud Config Server
● Fault Tolerance with Hystrix
Eureka Server
When you have multiple processes working together they need to find each
other. The developers at Netflix had this problem when building their systems
and created a registration server called Eureka (“I have found it” in Greek).
Fortunately for us, they made their discovery server open-source and Spring
has incorporated into Spring Cloud, making it even easier to run up a Eureka
server.
@SpringBootApplication
@EnableEurekaServer
public class ServiceRegistrationServer {
public static void main(String[] args) {
SpringApplication.run(ServiceRegistrationServer.class, args);
}
}
Configurations in application.properties
spring.application.name=netflix-eureka-naming-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
The configuration specifies that I am not a client and stops the server process trying to register with itself.
Eureka Server Application
Creating a Microservice
A microservice is a stand-alone process that handles a well-defined requirement.
When configuring applications with Spring we emphasize Loose Coupling and Tight Cohesion, These are
not new concepts (Larry Constantine is credited with first defining these in the late 1960s - reference) but
now we are applying them, not to interacting components (Spring Beans), but to interacting processes.
@SpringBootApplication
@EnableEurekaClient
public class AccountsService {
public static void main(String[] args) {
SpringApplication.run(AccountsService.class, args);
}
}
What makes this a microservice is the registration with the eureka-server via @EnableEurekaClient
In application.properties-
spring.application.name=account-service
server.port=8000
eureka.client.service-url.default-zone=http://localhost:8761/eureka
Note that this file -
● Sets the application name as accounts-service. This service registers under this name.
● Specifies a custom port to listen on (8000).
● The URL of the Eureka Service process - from the previous section.
Communicating with other microservices
Using RestTemplate -
To consume a RESTful service, Spring provides the RestTemplate class. This allows you to send HTTP
requests to a RESTful server and fetch data in a number of formats - such as JSON and XML.
public Account getByNumber(String accountNumber) {
Account account = new RestTemplate().getForObject(serviceUrl
+ "/accounts/{number}", Account.class, accountNumber);
if (account == null)
throw new AccountNotFoundException(accountNumber);
else
return account;
}
Using Feign (Spring cloud module)
@FeignClient(name="account-service" url="localhost:8000")
public interface AccountNumberServiceProxy {
@GetMapping("/accounts/{number}")
public Account retrieveAccount(@PathVariable("number") String number);
}
Enabling Feign clients -
Before we are able to use Feign, we need to enable it by using @EnableFeignClients annotation on the appropriate package where
the client proxies are defined.
@SpringBootApplication
@EnableFeignClients("com.springboot.microservice.example.account")
@EnableDiscoveryClient
public class AccountNumberServiceApplication {
public static void main(String[] args) {
SpringApplication.run(AccountNumberServiceApplication.class, args);
}
}
Load Balancing Using Ribbon
If you have multiple instances of a service available, ribbon picks one for you. (Eureka on their own
doesn’t perform load-balancing so we use Ribbon to do it instead).
Add dependency in build.gradle-
compile('org.springframework.cloud:spring-cloud-starter-ribbon')
@FeignClient(name="account-service")
@RibbonClient(name="account-service")
public interface AccountNumberServiceProxy {
@GetMapping("/accounts/{number}")
public Account retrieveAccount(@PathVariable("number") String number);
}
References
● https://spring.io/blog/2015/07/14/microservices-with-spring
● https://dzone.com/articles/microservices-with-spring-boot-part-1-getting-star
● https://github.com/paulc4/microservices-demo
● https://start.spring.io/
● http://www.baeldung.com/spring-cloud-netflix-eureka
Thank You..

Mais conteúdo relacionado

Mais procurados

Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data AccessDzmitry Naskou
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootJosué Neis
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample applicationAntoine Rey
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservicesAnil Allewar
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...Edureka!
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample applicationAnil Allewar
 
Introduction to Spring Cloud
Introduction to Spring Cloud           Introduction to Spring Cloud
Introduction to Spring Cloud VMware Tanzu
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action Alex Movila
 
Spring boot
Spring bootSpring boot
Spring bootsdeeg
 
Service discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudService discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudMarcelo Serpa
 

Mais procurados (20)

Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Framework - Data Access
Spring Framework - Data AccessSpring Framework - Data Access
Spring Framework - Data Access
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Spring Framework Petclinic sample application
Spring Framework Petclinic sample applicationSpring Framework Petclinic sample application
Spring Framework Petclinic sample application
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...What are Microservices | Microservices Architecture Training | Microservices ...
What are Microservices | Microservices Architecture Training | Microservices ...
 
Spring boot
Spring bootSpring boot
Spring boot
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample application
 
Introduction to Spring Cloud
Introduction to Spring Cloud           Introduction to Spring Cloud
Introduction to Spring Cloud
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring boot
Spring bootSpring boot
Spring boot
 
Service discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudService discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring Cloud
 

Semelhante a Springboot Microservices

Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideMohanraj Thirumoorthy
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Callon Campbell
 
Intro to spring cloud &microservices by Eugene Hanikblum
Intro to spring cloud &microservices by Eugene HanikblumIntro to spring cloud &microservices by Eugene Hanikblum
Intro to spring cloud &microservices by Eugene HanikblumEugene Hanikblum
 
Microservice creation using spring cloud, zipkin, ribbon, zull, eureka
Microservice creation using spring cloud, zipkin, ribbon, zull, eurekaMicroservice creation using spring cloud, zipkin, ribbon, zull, eureka
Microservice creation using spring cloud, zipkin, ribbon, zull, eurekaBinit Pathak
 
Netflix Cloud Platform and Open Source
Netflix Cloud Platform and Open SourceNetflix Cloud Platform and Open Source
Netflix Cloud Platform and Open Sourceaspyker
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with javaDPC Consulting Ltd
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & DevelopmentGlobalLogic Ukraine
 
SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSAOracle Korea
 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316Jupil Hwang
 
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...VMware Tanzu
 
.NET microservices with Azure Service Fabric
.NET microservices with Azure Service Fabric.NET microservices with Azure Service Fabric
.NET microservices with Azure Service FabricDavide Benvegnù
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayBizTalk360
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 
Sumo Logic Cert Jam - Advanced Metrics with Kubernetes
Sumo Logic Cert Jam - Advanced Metrics with KubernetesSumo Logic Cert Jam - Advanced Metrics with Kubernetes
Sumo Logic Cert Jam - Advanced Metrics with KubernetesSumo Logic
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014Hojoong Kim
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...Jitendra Bafna
 
Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Orkhan Gasimov
 
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...confluent
 
All About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksAll About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksMohammad Asif Siddiqui
 
Stream and Batch Processing in the Cloud with Data Microservices
Stream and Batch Processing in the Cloud with Data MicroservicesStream and Batch Processing in the Cloud with Data Microservices
Stream and Batch Processing in the Cloud with Data Microservicesmarius_bogoevici
 

Semelhante a Springboot Microservices (20)

Developing Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's GuideDeveloping Microservices using Spring - Beginner's Guide
Developing Microservices using Spring - Beginner's Guide
 
Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...Building stateful serverless orchestrations with Azure Durable Azure Function...
Building stateful serverless orchestrations with Azure Durable Azure Function...
 
Intro to spring cloud &microservices by Eugene Hanikblum
Intro to spring cloud &microservices by Eugene HanikblumIntro to spring cloud &microservices by Eugene Hanikblum
Intro to spring cloud &microservices by Eugene Hanikblum
 
Microservice creation using spring cloud, zipkin, ribbon, zull, eureka
Microservice creation using spring cloud, zipkin, ribbon, zull, eurekaMicroservice creation using spring cloud, zipkin, ribbon, zull, eureka
Microservice creation using spring cloud, zipkin, ribbon, zull, eureka
 
Netflix Cloud Platform and Open Source
Netflix Cloud Platform and Open SourceNetflix Cloud Platform and Open Source
Netflix Cloud Platform and Open Source
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
 
SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSA
 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316
 
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
Eseguire Applicazioni Cloud-Native con Pivotal Cloud Foundry su Google Cloud ...
 
.NET microservices with Azure Service Fabric
.NET microservices with Azure Service Fabric.NET microservices with Azure Service Fabric
.NET microservices with Azure Service Fabric
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications today
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Sumo Logic Cert Jam - Advanced Metrics with Kubernetes
Sumo Logic Cert Jam - Advanced Metrics with KubernetesSumo Logic Cert Jam - Advanced Metrics with Kubernetes
Sumo Logic Cert Jam - Advanced Metrics with Kubernetes
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
 
Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?
 
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
 
All About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksAll About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice Frameworks
 
Stream and Batch Processing in the Cloud with Data Microservices
Stream and Batch Processing in the Cloud with Data MicroservicesStream and Batch Processing in the Cloud with Data Microservices
Stream and Batch Processing in the Cloud with Data Microservices
 

Mais de NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Springboot Microservices

  • 1. Presented by - Ashish Gautam Spring Boot Microservices
  • 2. Agenda ● Introduction ● Comparison with monolith architecture ● Advantages of microservices ● Challenges with microservices ● Eureka server ● Creating a spring boot microservice ● Communicating with other microservices ● Load balancing
  • 3. Introduction Microservices is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. Microservices allow large systems to be built up from a number of collaborating components. It does at the process level what Spring has always done at the component level: loosely coupled processes instead of loosely coupled components.
  • 4. In comparison with Monolith application Monolith applications are typically huge - more 100,000 line of code. In some instances even more than million lines of code. Monoliths are characterized by - ● Large Application Size ● Long Release Cycles ● Large Teams
  • 5. Typical challenges in Monolith application ● Scalability challenges ● New technology adoption ● Difficult to perform automation tests ● Difficult to adapt to modern development practices ● Adapting to device explosion Microservice architectures evolved as a solution to the scalability and innovation challenges with monolithic architectures.
  • 6. What Does Microservice Architecture Look Like? This is how the same application would look like when developed using microservices architecture.
  • 7. Microservice architectures involve a number of small, well-designed components interacting with messages.
  • 8. Advantages of Microservices ● New technology and process adaptation becomes easier. You can try new technologies with the newer microservices that we create. ● Faster release cycles. ● Scaling with the cloud.
  • 9. ● Quick setup needed: You cannot spend a month setting up each microservice. You should be able to create microservices quickly. ● Automation: Because there are a number of smaller components instead of a monolith, you need to automate everything - Builds, Deployment, Monitoring, etc. ● Visibility: You now have a number of smaller components to deploy and maintain, maybe 100 or maybe 1000 components. You should be able to monitor and identify problems automatically. You need great visibility around all the components. ● Configuration Management: You need to maintain configurations for hundreds of components across environments. You would need a Configuration Management solution Challenges With Microservice Architectures
  • 10. Spring Boot Spring Boot enables building production-ready applications quickly and provides non-functional features: ● Embedded servers (easy deployment with containers) ● Metrics (monitoring) ● Health checks (monitoring) ● Externalized configuration Spring Cloud Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems. Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. Solutions to Challenges with Microservice Architectures
  • 11. Important Spring Cloud Modules ● Dynamically scale up and down. using a combination of ○ Naming Server (Eureka) ○ Ribbon (Client Side Load Balancing) ○ Feign (Easier REST Clients) ● Visibility and monitoring with ○ Zipkin Distributed Tracing ○ Netflix API Gateway ● Configuration Management with Spring Cloud Config Server ● Fault Tolerance with Hystrix
  • 12. Eureka Server When you have multiple processes working together they need to find each other. The developers at Netflix had this problem when building their systems and created a registration server called Eureka (“I have found it” in Greek). Fortunately for us, they made their discovery server open-source and Spring has incorporated into Spring Cloud, making it even easier to run up a Eureka server.
  • 13. @SpringBootApplication @EnableEurekaServer public class ServiceRegistrationServer { public static void main(String[] args) { SpringApplication.run(ServiceRegistrationServer.class, args); } } Configurations in application.properties spring.application.name=netflix-eureka-naming-server server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false The configuration specifies that I am not a client and stops the server process trying to register with itself. Eureka Server Application
  • 14. Creating a Microservice A microservice is a stand-alone process that handles a well-defined requirement. When configuring applications with Spring we emphasize Loose Coupling and Tight Cohesion, These are not new concepts (Larry Constantine is credited with first defining these in the late 1960s - reference) but now we are applying them, not to interacting components (Spring Beans), but to interacting processes.
  • 15. @SpringBootApplication @EnableEurekaClient public class AccountsService { public static void main(String[] args) { SpringApplication.run(AccountsService.class, args); } } What makes this a microservice is the registration with the eureka-server via @EnableEurekaClient In application.properties- spring.application.name=account-service server.port=8000 eureka.client.service-url.default-zone=http://localhost:8761/eureka Note that this file - ● Sets the application name as accounts-service. This service registers under this name. ● Specifies a custom port to listen on (8000). ● The URL of the Eureka Service process - from the previous section.
  • 16. Communicating with other microservices Using RestTemplate - To consume a RESTful service, Spring provides the RestTemplate class. This allows you to send HTTP requests to a RESTful server and fetch data in a number of formats - such as JSON and XML. public Account getByNumber(String accountNumber) { Account account = new RestTemplate().getForObject(serviceUrl + "/accounts/{number}", Account.class, accountNumber); if (account == null) throw new AccountNotFoundException(accountNumber); else return account; }
  • 17. Using Feign (Spring cloud module) @FeignClient(name="account-service" url="localhost:8000") public interface AccountNumberServiceProxy { @GetMapping("/accounts/{number}") public Account retrieveAccount(@PathVariable("number") String number); } Enabling Feign clients - Before we are able to use Feign, we need to enable it by using @EnableFeignClients annotation on the appropriate package where the client proxies are defined. @SpringBootApplication @EnableFeignClients("com.springboot.microservice.example.account") @EnableDiscoveryClient public class AccountNumberServiceApplication { public static void main(String[] args) { SpringApplication.run(AccountNumberServiceApplication.class, args); } }
  • 18. Load Balancing Using Ribbon If you have multiple instances of a service available, ribbon picks one for you. (Eureka on their own doesn’t perform load-balancing so we use Ribbon to do it instead). Add dependency in build.gradle- compile('org.springframework.cloud:spring-cloud-starter-ribbon') @FeignClient(name="account-service") @RibbonClient(name="account-service") public interface AccountNumberServiceProxy { @GetMapping("/accounts/{number}") public Account retrieveAccount(@PathVariable("number") String number); }
  • 19. References ● https://spring.io/blog/2015/07/14/microservices-with-spring ● https://dzone.com/articles/microservices-with-spring-boot-part-1-getting-star ● https://github.com/paulc4/microservices-demo ● https://start.spring.io/ ● http://www.baeldung.com/spring-cloud-netflix-eureka