SlideShare a Scribd company logo
Microservices and modularity with
Java
Elek Márton
@anzix
2015 December
DPC Consulting
Agenda
● Microservice definition
● Core implementation patterns
People need modularity not
microservices
Microservices is one way to achieve
modularity.
Other ways: OSGi, SPI, java9 jigsaw
What are microservices?
The fire making rule:
● Use more sticks than you think they would be
enough
● Use a little bit smaller sticks than you think would
be enough
Informal definition
Microservices when you have smaller, separated
services as usual
● Many times they are not micro (group of services)
● Many times REST is used (but not always)
● Separated means different process/JVM instances
More formal definition
● “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.
These services are built around business capabilities
and independently deployable by fully automated
deployment machinery.”
Lewis, Fowler
Microservices and REST
REST is just one solution to communicate
● between services
● or call any of the service
Microservices vs SOA
Even if the “Microservices != SOA” a very common
statement there are a lot of shared concept.
● Usually we have new tools (using existing solutions
differently) not totally new concept
Implementation patterns
Monolith application
Spring boot example
@EnableAutoConfiguration
@RestController
@ComponentScan
public class TimeStarter {
@Autowired
TimeService timerService;
@RequestMapping("/now")
public Date now() {
return timerService.now();
}
public static void main(String[] args) {
SpringApplication.run(TimeStarter.class, args);
}
}
Modular monolith
Microservices and modularity with java
API gateway
API gateway
Goals:
● Hide available microservices behind a service
facade pattern
– Routing, Authorization
– Deployment handling, Canary testing
– Logging, SLA
Implementations:
● Spring cloud: Netflix Zuul
● Netflix Zuul based implementation
● Twitter Finagle based implementation
● Amazon API gateway
● Simple Nginx reverse proxy configuration
Spring Cloud + Zuul example
@EnableAutoConfiguration
@ComponentScan
@EnableEurekaClient
@EnableZuulProxy
public class ApiGatewayStarter {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayStarter.class, args);
}
}
Microservices and modularity with java
Service registry
Service registry
Goal:
● Store the location and state of the available
services
– Health check
– DNS interface
Implementations:
● Spring cloud: Eureka
● Netflix eureka based implementation
● Consul.io
● etcd, zookeeper
● Simple: DNS or hosts file
Eureka
Eureka server
@SpringBootApplication
@EnableEurekaServer
public class EurekaStarter {
public static void main(String[] args) {
new SpringApplicationBuilder(EurekaStarter.class).web(true).run(args);
}
}
Eureka client
@EnableAutoConfiguration
@RestController
@ComponentScan
@EnableEurekaClient
public class TimeStarter {
@Autowired
TimeService tttService;
@RequestMapping("/now")
public Date now() {return tttService.now();}
public static void main(String[] args) {
SpringApplication.run(TimeStarter.class, args);
}
}
SIMPLE Discovery client
@Service
public class Client {
@Autowired
private DiscoveryClient discoveryClient;
public void list() {
for (ServiceInstance instance : discoveryClient.getInstances("BOOTSTRAP"))
{
System.out.println(instance.getHost());
System.out.println(instance.getPort());
System.out.println(instance.getUri());
}
}
}
Config service
Monolith configuration
● Store configuration outside of the project
– Versioning? Who did what
● Store configuration in separated versioned project
– Which binary version need which config version?
● Store configuration with the source code
– Sensitive configuration?
Config Service
Goals:
● One common place for all of the configuration
– Versioning
– Auditing
– Multiple environment support
Solutions:
● Spring Cloud config service
● Zookeeper
● Most of the service registry have key->value store
● Any persistence datastore
Config server
@SpringBootApplication
@EnableConfigServer
@EnableEurekaClient
public class ConfigServer {
public static void main(String[] args) {
new SpringApplicationBuilder(ConfigServer.class).run(args);
}
}
Config repository
elek@sc /tmp/config-repo [master] > ls -lah
drwxr-xr-x 3 elek elek 100 Dec 14 14:32 .
drwxrwxrwt 57 root root 1.8K Dec 14 14:37 ..
-rw-r--r-- 1 elek elek 55 Dec 14 14:16 application.properties
drwxr-xr-x 8 elek elek 260 Dec 14 14:40 .git
-rw-r--r-- 1 elek elek 12 Dec 14 14:32 timer.properties
Config client
@Service
public class TimeService {
@Value("${version:Unknown}")
String version;
public Date now() {
return new Date();
}
public String version() {
return version;
}
}
Monitoring
Monitoring
Goal:
● Combined business log
● Health check, exceptions, what is running?
● Metrics
Solutions (for one of the goals):
● Netflix Spectator, Servo, Atlas
● Spring cloud: Hystrix (circuit breaker)
● ELK: ElasticSearch + Logstash + Kibana
● Cloud based solutions (logentries...)
● Metrics: Dropwizard based implementations
Kibana (from ELK)
Hystrix
Hystrix
@Service
public class TimeService {
@HystrixCommand(fallbackMethod = "safeNow")
public Date now() {
return new Date();
}
public Date safeNow() {
return new Date(0);
}
}
Inter-module calls
Inter-module calls
Inter-module calls
Goal:
● RPC calls between modules
● Protocol
● Usage of the Service Registry
Solutions:
● Spring cloud/Netflix: ribbon
● Simple REST calls
● Message Oriented solutions:
– Rabbit MQ, ZMQ, ...
Distributed tracing
Distributed tracing (simlified)
Distributed tracing
Goal:
● Global information about latency and errors
– Service enter/exit point measurement
– Transaction identification
Implementations:
● Twitter’s Zipkin
● Apache (Cloudera) HTrace
● Spring cloud Sleuth
Zipkin
source: https://bitbucket.org/aktivecortex/aktivecortex/wiki/tracing.md
Summary
Advantages of monolith
Modular monolith Microservices
Advantages of microservices
● Modular, loosely coupled
● Easily scalable to multiple machines
● Separated, modular development lifecycle
● Partial deploy without restart [like OSGi]
● Supports heterogeneous architecture (tech stack
migration)
Summary
● Focus on modularity
● Be familiar with the microservice related tools: they
could be useful even with monolith applications…
Start with monolith?
Stefan Tilkov:
http://martinfowler.com/articles/dont-
start-monolith.html
Martin Fowler:
http://martinfowler.com/bliki/MonolithFirst.
html
Q&A
Márton Elek
DPC consulting http://dpc.hu
twitter: @anzix
http://blog.dpc.hu, http://blog.anzix.net

More Related Content

What's hot (20)

PPTX
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES HAS NEVER BEEN SO EASY
Red Hat Developers
 
PDF
GUJavaSC - Criando Micro-serviços Reativos com Java
Rodrigo Cândido da Silva
 
PDF
How lagom helps to build real world microservice systems
Markus Eisele
 
PDF
Crafting Kubernetes Operators
Red Hat Developers
 
PDF
The evolving container landscape
Nilesh Trivedi
 
PPT
Sebastien goasguen cloud stack and docker
ShapeBlue
 
PPTX
Building Cloud Native Applications Using Spring Boot and Spring Cloud
GeekNightHyderabad
 
PDF
Rohit yadav cloud stack internals
ShapeBlue
 
PDF
Microservices with Spring Cloud
Daniel Eichten
 
PDF
CDK Meetup: Rule the World through IaC
smalltown
 
ODP
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Codemotion
 
PPTX
Building Micro-Services with Scala
Yardena Meymann
 
PPTX
Serverless and Servicefull Applications - Where Microservices complements Ser...
Red Hat Developers
 
PDF
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
smalltown
 
PDF
Slick eventsourcing
Adam Warski
 
PPTX
IPaaS 2.0: Fuse Integration Services (Robert Davies & Keith Babo)
Red Hat Developers
 
PDF
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
PDF
Security model for a remote company
Pierre Mavro
 
PDF
Microservices with Spring Cloud and Netflix OSS
Denis Danov
 
PDF
Lagom : Reactive microservice framework
Fabrice Sznajderman
 
KUBEBOOT - SPRING BOOT DEPLOYMENT ON KUBERNETES HAS NEVER BEEN SO EASY
Red Hat Developers
 
GUJavaSC - Criando Micro-serviços Reativos com Java
Rodrigo Cândido da Silva
 
How lagom helps to build real world microservice systems
Markus Eisele
 
Crafting Kubernetes Operators
Red Hat Developers
 
The evolving container landscape
Nilesh Trivedi
 
Sebastien goasguen cloud stack and docker
ShapeBlue
 
Building Cloud Native Applications Using Spring Boot and Spring Cloud
GeekNightHyderabad
 
Rohit yadav cloud stack internals
ShapeBlue
 
Microservices with Spring Cloud
Daniel Eichten
 
CDK Meetup: Rule the World through IaC
smalltown
 
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Codemotion
 
Building Micro-Services with Scala
Yardena Meymann
 
Serverless and Servicefull Applications - Where Microservices complements Ser...
Red Hat Developers
 
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
smalltown
 
Slick eventsourcing
Adam Warski
 
IPaaS 2.0: Fuse Integration Services (Robert Davies & Keith Babo)
Red Hat Developers
 
Spring Boot Revisited with KoFu and JaFu
VMware Tanzu
 
Security model for a remote company
Pierre Mavro
 
Microservices with Spring Cloud and Netflix OSS
Denis Danov
 
Lagom : Reactive microservice framework
Fabrice Sznajderman
 

Viewers also liked (20)

PDF
Microservices Architecture
Izzet Mustafaiev
 
ODP
Microservice Architecture JavaCro 2015
Nenad Pecanac
 
PDF
Két Java fejlesztő első Scala projektje
DPC Consulting Ltd
 
PPTX
Microservices with MSF4J - WSO2 Meetup
Afkham Azeez
 
PPTX
Java SE 8 - New Features
Naveen Hegde
 
PDF
Microservices - stress-free and without increased heart-attack risk - Uwe Fri...
distributed matters
 
PDF
Server in your Client
DPC Consulting Ltd
 
PPTX
Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...
Codefresh
 
PPTX
JavaOne: Efficiently building and deploying microservices
Bart Blommaerts
 
PPTX
Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0
Afkham Azeez
 
PDF
DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"
Daniel Bryant
 
PDF
How Small Can Java Microservices Be?
Eberhard Wolff
 
PDF
Java Microservices with Netflix OSS & Spring
Conor Svensson
 
PDF
Microservice no fluff, the REAL stuff
nklmish
 
PPTX
MicroserviceArchitecture in detail over Monolith.
PLovababu
 
PDF
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
Dennis Traub
 
PPTX
Microservices in Action
Bhagwat Kumar
 
PDF
Deploying Microservices to Cloud Foundry
Matt Stine
 
PDF
Microservices: Architecture for Agile Software Development
Eberhard Wolff
 
PDF
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
Microservices Architecture
Izzet Mustafaiev
 
Microservice Architecture JavaCro 2015
Nenad Pecanac
 
Két Java fejlesztő első Scala projektje
DPC Consulting Ltd
 
Microservices with MSF4J - WSO2 Meetup
Afkham Azeez
 
Java SE 8 - New Features
Naveen Hegde
 
Microservices - stress-free and without increased heart-attack risk - Uwe Fri...
distributed matters
 
Server in your Client
DPC Consulting Ltd
 
Containers #101 Meetup: Building a micro-service using Node.js and Docker - P...
Codefresh
 
JavaOne: Efficiently building and deploying microservices
Bart Blommaerts
 
Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0
Afkham Azeez
 
DevoxxUK 2015 "The Seven Deadly Sins of Microservices (Full Version)"
Daniel Bryant
 
How Small Can Java Microservices Be?
Eberhard Wolff
 
Java Microservices with Netflix OSS & Spring
Conor Svensson
 
Microservice no fluff, the REAL stuff
nklmish
 
MicroserviceArchitecture in detail over Monolith.
PLovababu
 
DDD / Microservices @ Trivento Spring Camp, Utrecht, 2015
Dennis Traub
 
Microservices in Action
Bhagwat Kumar
 
Deploying Microservices to Cloud Foundry
Matt Stine
 
Microservices: Architecture for Agile Software Development
Eberhard Wolff
 
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
Ad

Similar to Microservices and modularity with java (20)

PPTX
Microservices
Ramesh (@Mavuluri)
 
PPTX
Microservices Corporate Style
Narendranath Reddy
 
PPTX
Intro to spring cloud &microservices by Eugene Hanikblum
Eugene Hanikblum
 
PPTX
Spring cloud-netflix-oss-microservices
Staples
 
PPTX
Microservice creation using spring cloud, zipkin, ribbon, zull, eureka
Binit Pathak
 
PPTX
Springboot Microservices
NexThoughts Technologies
 
PPTX
Micro services Architecture
Jenis Dharmadurai
 
PPTX
Microservices, Spring Cloud & Cloud Foundry
Emilio Garcia
 
PDF
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
PDF
Building ‘Bootiful’ microservices cloud
Idan Fridman
 
PDF
Spring cloud
Milan Ashara
 
PDF
Cloudify your applications: microservices and beyond
Ugo Landini
 
PPTX
MicroService Architecture
Md. Hasan Basri (Angel)
 
PDF
Azure Spring Cloud Workshop - June 17, 2020
VMware Tanzu
 
PDF
Microservices on a budget meetup
Matthew Reynolds
 
PDF
Full lifecycle of a microservice
Luigi Bennardis
 
ODP
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
ODP
Spring cloud for microservices architecture
Igor Khotin
 
PDF
Migrating Monoliths to Microservices -- M3
Asir Selvasingh
 
PDF
Microservices with Spring Cloud
Krzysztof Miernik
 
Microservices
Ramesh (@Mavuluri)
 
Microservices Corporate Style
Narendranath Reddy
 
Intro to spring cloud &microservices by Eugene Hanikblum
Eugene Hanikblum
 
Spring cloud-netflix-oss-microservices
Staples
 
Microservice creation using spring cloud, zipkin, ribbon, zull, eureka
Binit Pathak
 
Springboot Microservices
NexThoughts Technologies
 
Micro services Architecture
Jenis Dharmadurai
 
Microservices, Spring Cloud & Cloud Foundry
Emilio Garcia
 
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
Building ‘Bootiful’ microservices cloud
Idan Fridman
 
Spring cloud
Milan Ashara
 
Cloudify your applications: microservices and beyond
Ugo Landini
 
MicroService Architecture
Md. Hasan Basri (Angel)
 
Azure Spring Cloud Workshop - June 17, 2020
VMware Tanzu
 
Microservices on a budget meetup
Matthew Reynolds
 
Full lifecycle of a microservice
Luigi Bennardis
 
Developing Microservices using Spring - Beginner's Guide
Mohanraj Thirumoorthy
 
Spring cloud for microservices architecture
Igor Khotin
 
Migrating Monoliths to Microservices -- M3
Asir Selvasingh
 
Microservices with Spring Cloud
Krzysztof Miernik
 
Ad

More from DPC Consulting Ltd (6)

PDF
Scaling on AWS
DPC Consulting Ltd
 
PDF
Jsonp coding dojo
DPC Consulting Ltd
 
PDF
Garbage First Garbage Collector Algorithm
DPC Consulting Ltd
 
PDF
OSGi as Enterprise Integration Platform
DPC Consulting Ltd
 
PDF
Full stack security
DPC Consulting Ltd
 
PDF
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
Scaling on AWS
DPC Consulting Ltd
 
Jsonp coding dojo
DPC Consulting Ltd
 
Garbage First Garbage Collector Algorithm
DPC Consulting Ltd
 
OSGi as Enterprise Integration Platform
DPC Consulting Ltd
 
Full stack security
DPC Consulting Ltd
 
Java 9 and Project Jigsaw
DPC Consulting Ltd
 

Recently uploaded (20)

PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PDF
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
DOCX
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
PPT
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
PPTX
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PPTX
darshai cross section and river section analysis
muk7971
 
PPTX
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PDF
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PPTX
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
FINAL plumbing code for board exam passer
MattKristopherDiaz
 
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
darshai cross section and river section analysis
muk7971
 
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
Functions in Python Programming Language
BeulahS2
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
Engineering Quiz ShowEngineering Quiz Show
CalvinLabial
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 

Microservices and modularity with java