SlideShare ist ein Scribd-Unternehmen logo
1 von 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..

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservicesAnil Allewar
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample applicationAnil Allewar
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Microservices
MicroservicesMicroservices
MicroservicesSmartBear
 
Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Orkhan Gasimov
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Edureka!
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetesrajdeep
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSHoang Long
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To JenkinsKnoldus Inc.
 

Was ist angesagt? (20)

Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
Building microservices sample application
Building microservices sample applicationBuilding microservices sample application
Building microservices sample application
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Microservices
MicroservicesMicroservices
Microservices
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?Spring Cloud: Why? How? What?
Spring Cloud: Why? How? What?
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
 
Express js
Express jsExpress js
Express js
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 

Ähnlich wie 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
 
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
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...MSDEVMTL
 

Ähnlich wie 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 ...
 
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
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
 

Mehr von 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
 

Kürzlich hochgeladen

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
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?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 

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