2. In short, the microservice architectural style 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.These services are built around business
capabilities and independently deployable by fully automated
deployment machinery.There is a bare minimum of centralized
management of these services, which may be written in different
programming languages and use different data storage technologies.
-- James Lewis and Martin Fowler
3. …suite of small services…
The service can be rewritten and redeployed in 2 weeks
-- Jon Eaves, realestate.com.au
4. …suite of small services…
https://queue.acm.org/detail.cfm?id=1142065
If you hit the Amazon.com gateway page, the application calls
more than 100 services to collect data and construct the page
for you.
-- WernerVogels, 2006, interview Web Services
7. …suite of small services…
“two pizza teams”
-- Jeff Bezos,Amazon
8. …running in its own process…
http://martinfowler.com/articles/microservices.html
9. …built around business capabilities…
Any organization that designs a system (defined broadly) will
produce a design whose structure is a copy of the
organization's communication structure.
-- Melvyn Conway
=
software structure reflects organisation structure
10. …built around business capabilities…
UI
Business Logic
Database
frontend devs
backend devs
DBAs
13. Each service has a team associated with it, and that team is
completely responsible for the service — from scoping
out the functionality, to architecting it, to building it, and
operating it. (…) Giving developers operational responsibilities
has greatly enhanced the quality of the services.
-- WernerVogels,Amazon
service
ownership
Build DeployTest
14. …independently deployable…
You don’t go and have a deep discussion with the
Google Maps team just to use their Maps API: it's a
reasonably stable API, you are isolated, it's sort of versioned,
occasionally it changes and you may want to do things.
-- Adrian Cockroft, (2010-2013 Netflix)
http://www.infoq.com/interviews/adrian-cockcroft-microservices-devops
16. …bare minimum of centralised management…
=
decentralise all things
17. MICRO SERVICES WITH
SPRING BOOT
$ spring init --dependencies=web micro-service-1
$ spring init --list
$ spring init --build=gradle --java-version=1.8
--dependencies=websocket --packaging=war
customized-project
$ spring run . -- --server.port=9000
$ spring test .
$ java -jar target/micro-service-1.jar
18. MICRO SERVICES WITH
SPRING BOOT
@RestController
public class MicroController2 {
@RequestMapping("/service2")
public String service2() {
return "Hello from service 2";
}
}
@RestController
public class MicroController1 {
@RequestMapping("/service1")
public String service1() {
RestTemplate rest = new RestTemplate();
String response = rest.getForObject(
"http://localhost:9002/service2", String.class);
return "Response from service2: " + response;
}
}
19. ADVANTAGES
• cheap to scale
• fast to replace
• fault tolerant (resilient)
• promote modularity
• parallelize development
20. DISADVANTAGES
• network is not deterministic
• lack of testing end-to-end
• complicated deploy and versioning
• a lot of new tools
• eventual consistency in favour of transactions
• more work and bigger dev costs
23. MICROSERVICESVS SOA
With SOA, the intent is a layered architecture of co-operating services where SOA
focuses on describing the organisation and co-ordination of the services.With
micro services, the intent is to describe the nature of the services themselves and
not quite so much the organisation and co-ordination of them.
-- Jon Eaves, realestate.com.au
24. MICROSERVICESVS SOA
We have gone from building a single ball of mud to
orchestrating a lot of shit
-- Hadi Hariri
25. MICROSERVICESVS SOA
SOA means too many different things
-- Martin Fowler
http://martinfowler.com/bliki/ServiceOrientedAmbiguity.html
31. YOU MUST BETHISTALLTO
USE MICRO SERVICES
http://martinfowler.com/bliki/MicroservicePrerequisites.html
32. YOU MUST BETHISTALLTO
USE MICRO SERVICES
• DevOps
• Continous Delivery
no SSH to server
realtime monitoring
build pipeline
click to deploy
culture of
automation
33. IS IT WORTH DITCHING
THE MONOLITH?
• 95% cases: totally not worth it
• dvd.netflix.com: monolith for 6 mln users (2015)
34. MICROSERVICESVS
MONOLITH
Monolithic deployment of multiple components
within a single WAR still remains the simplest
possible solution for a mainstream project without
any additional requirements. Unfortunately, simplest
possible solutions are usually not buzzword-
compatible :-).
-- Adam Bien
42. STRANGLER PATTERN
Gradually create a new system around the
edges of the old, letting it grow slowly over
several years until the old system is strangled.
-- Martin Fowler
http://martinfowler.com/bliki/StranglerApplication.html
52. AVOID SHARED
DEPENDENCY
Don’t violate DRY within a micro service,
but be relaxed about violating DRY across
all services.
-- Sam Newman,“Building Microservices”
60. Our main focus is system containers.That is,
containers which offer an environment
as close to possible as the one you'd get
from a VM but without the overhead
that comes with running a separate kernel
and simulating all the hardware.
-- linuxcontainers.org