SlideShare a Scribd company logo
Developing
Microservices
using Spring
-
Beginners Guide
* Disclaimer: There are various topics covered in this session, each topic is worth a 2 day workshop session in itself, so this will cover only the very basics and try
to provide a birds eye view of the various concepts.
Agenda
● Microservices
● What ?
● Why ?
● Challenges of a distributed system
● Building Microservices using Spring
● Spring Boot
● Spring Cloud & Netflix OSS
● Conclusion
All Roads Lead to Microservices
Cloud
aPaaS
Continuous Delivery
Dev Ops
Agile
Microservices
Microservices – What ?
The term "Microservice Architecture" has sprung up over the
last few years to describe a particular way of designing
software applications as suites of independently deployable
services.
-Martin Fowler
http://martinfowler.com/articles/microservices.html
Microservices are loosely coupled service oriented
architecture with bounded contexts.
- Adrian Cockroft
Monolith Application
● Imaginary E-Commerce App
● Very efficient inter process calls between
components
● Good architecture, until it needs to scale
during busy shopping season.
Monolith Application
● You want to scale only 'Shopping
Cart' and 'Checkout' Modules,
but instead have to scale the
entire App
● Other Challenges with multiple
database and Session
management
Monolith Application – Good Parts
● Contains Everything
● Single Deployment
● Minimum viable product can
be reached quickly
● Easy (or Familiar) to understand
Monolith Application – Bad Parts
● Complex Architecture
● Difficult to Scale
(cannot scale only selected
modules)
● Long term commitment
to one technical stack
Microservices
● Distillation of SOA
● Single Context
● Smart Services / Dumb Pipes
● RESTful Communications
● Smaller codebase – easy to
reason about
● Easy to scale
Microservices
Challenges of distributed system
● Configuration Management
● Service Registration & Discovery
● Load Balancing
● Fault Tolerance
● Monitoring
● Concurrent API Integration & Transformation
*(This is not a complete list...)
Spring Boot
● Built on top of Spring framework
● Opinionated convention over configuration
● Creates stand-alone “Production” ready app
● Embedded Tomcat / Jetty
● Various Starters POMs to simplify configuration
● https://start.spring.io/ - Spring Initializr template project (We can
replace our kick start scripts with something like this)
Spring Boot
● It can get pretty small..
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
Exercise 1 : Spring Boot Hello World
Spring Boot
● Retrieve data from database – Spring Data REST
● Entity Class
@Entity
@Table(name="users")
public class User implements Serializable{... }
● Repository Class
@Repository
public interface UserRepository extends JpaRepository<User, Integer> { }
● Main Class
@SpringBootApplication
public class SampleDataJpaApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleDataJpaApplication.class, args);
}
}
● The same project runs in local and Cloud - PWS
Exercise 2 : Spring Data REST
Spring Cloud
● Writing a single service with Spring Boot is easy.
● But things gets complex with managing multiple services
● http://cloud.spring.io/spring-cloud-netflix/ , to the rescue.
● Similar to Spring Data umbrella project.
Spring Cloud Netflix
● Configuration Management – Spring Cloud Config
● Service Registration & Discovery – Eureka
● Load Balancing – Feign & Ribbon
● Fault Tolerance (Circuit Breaker) – Hysterix
● Monitoring – Hysterix Dashboard
● Concurrent API Integration & Transformation - RxJava
Spring Cloud Config
● Distributed configuration management.
● Provides server and client-side support for externalized configuration.
● Store Configuration properties (YAML content) in remote repository (Git
supported by default)
● Curl -X POST http://localhost:8888/bus/refresh, to get the latest values from
the config server.
Exercise 3 : Config Server
Cloud Bus (AMQP / RabbitMQ)
Git (default)
properties
Config Server
/refresh
/refresh
Service Registry & Discovery - Eureka
● Eureka is Netflix OSS Project for Service Discovery Server & Client.
● Eureka Server – can be configured to be highly available, supports server
replication for resiliency.
● Clients registers with Eureka and sends heartbeat messages to Server.
● Eureka Server
@EnableEurekaServer
class Eureka {
}
● Eureka Client
@EnableDiscoveryClient
public class Application {... }
● Producer Consumer example
Exercise 4 : Eureka – Producer / Consumer
Load balancing - Ribbon
● Ribbon is a Netflix OSS Project, it provides software load balancers with
cluster of servers.
● Provides basic functionality like supply the public DNS name of servers
to client, rotate among the list of servers according to certain logic.
● Load balancer components
Rule – logic to determine which server to return from the serverlist.
Ping – to ensure server liveness
ServerList – can be static or dynamic
● Spring RestTemplate has been added with little bit of magic and made
Ribbon enabled.
● FeignClient is alternative to Spring RestTemplate, Feign is declarative
web service client, makes writing web service clients easier.
Exercise 5 : Producer / Consumer example with load balancer / Feign
Fault Tolerance - Hystrix
● Hystrix – Circuit Breaker Pattern
● Its a state machine, with 3 states – Closed, Open and Half-Open.
● Failures does not cascade up to the top of the call stack.
Exercise 6 : Hystrix in action
Monitoring
● Hystrix Dashboard
Import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard
@EnableHystrixDashboard
class HystrixDashboard { … }
Exercise 7 : Hystrix Dashboard in action
Concurrent API Integration - RxJava
● RxJava is Java implementation of MS
Reactive Extensions.
● A library for composing asynchronous
and event-based programs by using
Observable sequences.
● Netflix created RxJava to simplify
server side concurrency, a single
“heavy” client request that is executed
in parallel on the server.
● The service layer API method return an Observable<T> getData(), this can be
asynch or synch, and its transparent to the caller of this service.
● Can be achieved using Java Futures, but it supports one value, not for a
sequences. Also calling Future.get() will be a blocking.
● Callbacks can be used for asynchronous execution and works well for single level
of execution, but things gets complicated with nested Callbacks (callback hell !).
Conclusion
● Microservices Architectural Style needs certain infrastructure competencies
like, Rapid Provisioning, Continuous Delivery, Basic Monitoring, etc.,
● There are many new design patterns to learn when implementing a
distributed system.
● Spring Cloud Netflix implements certain patterns and Spring Boot makes it
easy to use.
References
● http://martinfowler.com/articles/microservices.html
● http://martinfowler.com/bliki/MicroservicePrerequisites.html
● http://projects.spring.io/spring-boot/
● http://projects.spring.io/spring-cloud/
● http://cloud.spring.io/spring-cloud-netflix/
● http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
● https://github.com/ReactiveX/RxJava
● http://www.infoq.com/presentations/reactive-arch-grails
● http://www.infoq.com/presentations/Netflix-API-rxjava-hystrix
Images
● https://www.flickr.com/photos/bhophoto/384574407/

More Related Content

What's hot

Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudIdan Fridman
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminarGal Marder
 
Spring Boot
Spring BootSpring Boot
Spring Bootgedoplan
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAlex Thissen
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
Validating latest changes with XCI
Validating latest changes with XCIValidating latest changes with XCI
Validating latest changes with XCIVictor Morales
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019J V
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfileRudy De Busscher
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014Amazon Web Services
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with ConsulVMware Tanzu
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessStrannik_2013
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»DataArt
 
How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...Victor Morales
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesJeff Potts
 
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyKKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyLiyao Chen
 
ASP.NET Core Demos
ASP.NET Core DemosASP.NET Core Demos
ASP.NET Core DemosErik Noren
 

What's hot (20)

Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloud
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Validating latest changes with XCI
Validating latest changes with XCIValidating latest changes with XCI
Validating latest changes with XCI
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfile
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with Consul
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happiness
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
 
How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to Microservices
 
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyKKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - Antony
 
ASP.NET Core Demos
ASP.NET Core DemosASP.NET Core Demos
ASP.NET Core Demos
 
Containerize!
Containerize!Containerize!
Containerize!
 

Similar to Developing Microservices using Spring - Beginner's Guide

Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with javaDPC Consulting Ltd
 
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
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice frameworkFabrice Sznajderman
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAndrei Sebastian Cîmpean
 
Introduction to Lagom Framework
Introduction to Lagom FrameworkIntroduction to Lagom Framework
Introduction to Lagom FrameworkKnoldus Inc.
 
Microservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesMicroservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesQAware GmbH
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksRuslan Meshenberg
 
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
 
Drools & jBPM future roadmap talk
Drools & jBPM future roadmap talkDrools & jBPM future roadmap talk
Drools & jBPM future roadmap talkMark Proctor
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC vipin kumar
 
Scale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceScale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceIRJET Journal
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLNordic APIs
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaMax Alexejev
 
Pivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookPivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookVMware Tanzu
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction Hitesh-Java
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...Jitendra Bafna
 

Similar to Developing Microservices using Spring - Beginner's Guide (20)

Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
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
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Java one2013
Java one2013Java one2013
Java one2013
 
Introduction to Lagom Framework
Introduction to Lagom FrameworkIntroduction to Lagom Framework
Introduction to Lagom Framework
 
Microservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesMicroservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing Microservices
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
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
 
Drools & jBPM future roadmap talk
Drools & jBPM future roadmap talkDrools & jBPM future roadmap talk
Drools & jBPM future roadmap talk
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC
 
Scale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceScale and Load Testing of Micro-Service
Scale and Load Testing of Micro-Service
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of ML
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
Pivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookPivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First Look
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
AKS: k8s e azure
AKS: k8s e azureAKS: k8s e azure
AKS: k8s e azure
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform EngineeringJemma Hussein Allen
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»QADay
 
UiPath New York Community Day in-person event
UiPath New York Community Day in-person eventUiPath New York Community Day in-person event
UiPath New York Community Day in-person eventDianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
UiPath New York Community Day in-person event
UiPath New York Community Day in-person eventUiPath New York Community Day in-person event
UiPath New York Community Day in-person event
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Developing Microservices using Spring - Beginner's Guide

  • 1. Developing Microservices using Spring - Beginners Guide * Disclaimer: There are various topics covered in this session, each topic is worth a 2 day workshop session in itself, so this will cover only the very basics and try to provide a birds eye view of the various concepts.
  • 2. Agenda ● Microservices ● What ? ● Why ? ● Challenges of a distributed system ● Building Microservices using Spring ● Spring Boot ● Spring Cloud & Netflix OSS ● Conclusion
  • 3. All Roads Lead to Microservices Cloud aPaaS Continuous Delivery Dev Ops Agile Microservices
  • 4. Microservices – What ? The term "Microservice Architecture" has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. -Martin Fowler http://martinfowler.com/articles/microservices.html Microservices are loosely coupled service oriented architecture with bounded contexts. - Adrian Cockroft
  • 5. Monolith Application ● Imaginary E-Commerce App ● Very efficient inter process calls between components ● Good architecture, until it needs to scale during busy shopping season.
  • 6. Monolith Application ● You want to scale only 'Shopping Cart' and 'Checkout' Modules, but instead have to scale the entire App ● Other Challenges with multiple database and Session management
  • 7. Monolith Application – Good Parts ● Contains Everything ● Single Deployment ● Minimum viable product can be reached quickly ● Easy (or Familiar) to understand
  • 8. Monolith Application – Bad Parts ● Complex Architecture ● Difficult to Scale (cannot scale only selected modules) ● Long term commitment to one technical stack
  • 9. Microservices ● Distillation of SOA ● Single Context ● Smart Services / Dumb Pipes ● RESTful Communications ● Smaller codebase – easy to reason about ● Easy to scale
  • 11. Challenges of distributed system ● Configuration Management ● Service Registration & Discovery ● Load Balancing ● Fault Tolerance ● Monitoring ● Concurrent API Integration & Transformation *(This is not a complete list...)
  • 12. Spring Boot ● Built on top of Spring framework ● Opinionated convention over configuration ● Creates stand-alone “Production” ready app ● Embedded Tomcat / Jetty ● Various Starters POMs to simplify configuration ● https://start.spring.io/ - Spring Initializr template project (We can replace our kick start scripts with something like this)
  • 13. Spring Boot ● It can get pretty small.. @RestController class ThisWillActuallyRun { @RequestMapping("/") String home() { "Hello World!" } } Exercise 1 : Spring Boot Hello World
  • 14. Spring Boot ● Retrieve data from database – Spring Data REST ● Entity Class @Entity @Table(name="users") public class User implements Serializable{... } ● Repository Class @Repository public interface UserRepository extends JpaRepository<User, Integer> { } ● Main Class @SpringBootApplication public class SampleDataJpaApplication { public static void main(String[] args) throws Exception { SpringApplication.run(SampleDataJpaApplication.class, args); } } ● The same project runs in local and Cloud - PWS Exercise 2 : Spring Data REST
  • 15. Spring Cloud ● Writing a single service with Spring Boot is easy. ● But things gets complex with managing multiple services ● http://cloud.spring.io/spring-cloud-netflix/ , to the rescue. ● Similar to Spring Data umbrella project.
  • 16. Spring Cloud Netflix ● Configuration Management – Spring Cloud Config ● Service Registration & Discovery – Eureka ● Load Balancing – Feign & Ribbon ● Fault Tolerance (Circuit Breaker) – Hysterix ● Monitoring – Hysterix Dashboard ● Concurrent API Integration & Transformation - RxJava
  • 17. Spring Cloud Config ● Distributed configuration management. ● Provides server and client-side support for externalized configuration. ● Store Configuration properties (YAML content) in remote repository (Git supported by default) ● Curl -X POST http://localhost:8888/bus/refresh, to get the latest values from the config server. Exercise 3 : Config Server Cloud Bus (AMQP / RabbitMQ) Git (default) properties Config Server /refresh /refresh
  • 18. Service Registry & Discovery - Eureka ● Eureka is Netflix OSS Project for Service Discovery Server & Client. ● Eureka Server – can be configured to be highly available, supports server replication for resiliency. ● Clients registers with Eureka and sends heartbeat messages to Server. ● Eureka Server @EnableEurekaServer class Eureka { } ● Eureka Client @EnableDiscoveryClient public class Application {... } ● Producer Consumer example Exercise 4 : Eureka – Producer / Consumer
  • 19. Load balancing - Ribbon ● Ribbon is a Netflix OSS Project, it provides software load balancers with cluster of servers. ● Provides basic functionality like supply the public DNS name of servers to client, rotate among the list of servers according to certain logic. ● Load balancer components Rule – logic to determine which server to return from the serverlist. Ping – to ensure server liveness ServerList – can be static or dynamic ● Spring RestTemplate has been added with little bit of magic and made Ribbon enabled. ● FeignClient is alternative to Spring RestTemplate, Feign is declarative web service client, makes writing web service clients easier. Exercise 5 : Producer / Consumer example with load balancer / Feign
  • 20. Fault Tolerance - Hystrix ● Hystrix – Circuit Breaker Pattern ● Its a state machine, with 3 states – Closed, Open and Half-Open. ● Failures does not cascade up to the top of the call stack. Exercise 6 : Hystrix in action
  • 21. Monitoring ● Hystrix Dashboard Import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard @EnableHystrixDashboard class HystrixDashboard { … } Exercise 7 : Hystrix Dashboard in action
  • 22. Concurrent API Integration - RxJava ● RxJava is Java implementation of MS Reactive Extensions. ● A library for composing asynchronous and event-based programs by using Observable sequences. ● Netflix created RxJava to simplify server side concurrency, a single “heavy” client request that is executed in parallel on the server. ● The service layer API method return an Observable<T> getData(), this can be asynch or synch, and its transparent to the caller of this service. ● Can be achieved using Java Futures, but it supports one value, not for a sequences. Also calling Future.get() will be a blocking. ● Callbacks can be used for asynchronous execution and works well for single level of execution, but things gets complicated with nested Callbacks (callback hell !).
  • 23. Conclusion ● Microservices Architectural Style needs certain infrastructure competencies like, Rapid Provisioning, Continuous Delivery, Basic Monitoring, etc., ● There are many new design patterns to learn when implementing a distributed system. ● Spring Cloud Netflix implements certain patterns and Spring Boot makes it easy to use.
  • 24. References ● http://martinfowler.com/articles/microservices.html ● http://martinfowler.com/bliki/MicroservicePrerequisites.html ● http://projects.spring.io/spring-boot/ ● http://projects.spring.io/spring-cloud/ ● http://cloud.spring.io/spring-cloud-netflix/ ● http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html ● https://github.com/ReactiveX/RxJava ● http://www.infoq.com/presentations/reactive-arch-grails ● http://www.infoq.com/presentations/Netflix-API-rxjava-hystrix Images ● https://www.flickr.com/photos/bhophoto/384574407/