Microservices are a true hype these days. Netflix, Amazon, eBay, … are all using microservices, but why? The idea is simple; split your application into multiple services which can evolve autonomously through time. The name suggests to keep these services small. Conceptually this seems not all that different from a classical Service Oriented Architecture (SOA). Nonetheless, microservices do offer a new perspective. A monolithic application is divided into a couple small services which can be independently developed, deployed and scaled. Flexibility is increased, but using this model also has some pitfalls.This session sheds a light on the microservices landscape; the key drivers for using the pattern, tooling to support development and maintenance, and the pros and cons that go with it. We’ll also introduce some key design principles that can be used in creating and modelling these modular enterprise applications.
2. Martin Fowler
“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
14. SERVICE ORIENTED ARCHITECTURE?
Yes, it’s SOA … but different implementation approach:
Classic SOA
integrates different applications as a set of services
Microservices
architect a single application as a set of services
15. Classic SOA
integrates different applications as a set of services
Enterprise Service Bus
WS* WS* WS* WS* WS*
WS* WS* WS* WS* WS*
Workflow Engine
Intelligence
Orchestration
16. Microservices
architect a single application as a set of services
business platform
accounting
service contract
service
ordering
service
logistics
service
prospects
service
capability X
service
capability Y
service
external integrationsbackends
{ API } { API }{ API }
{ API } { API }
{ API }
{ API }
{ API }
{ API }
{ API } { API }
17. Classic SOA
integrates different applications as a set of services
Microservices
architect a single application as a set of services
Typical implementation solution differs!
Heavy-weight
ESB
WS*/SOAP
Orchestration
License-driven
Target problem:
Integrate (Legacy) Software
Intelligent Communication Layer
Light-weight
HTTP/REST/JSON
Choreography
Target problem:
Architect new Business Platform
Dumb Communication Layer
Intelligent Services
19. side note: Domain Driven Design
Tackling complexity by abstracting the business domain concepts and logic into a
domain model and using this as a base for software development
“In order to create good software, you have to know what that software is all about. You
cannot create a banking software system unless you have a good understanding of what
banking is all about, one must understand the domain of banking.”
Eric Evans
20. Domain driven design deals with large complex models by dividing them into
different functionally bounded subdomains and the explicitly describing the
interrelations between these subdomains.
Bounded contexts
22. Functional decomposition of the business domain
AccountingInventory
BillingOrdering
customer
Invoice
balance
order
item
item
stock order
order
item
incoming cash
outgoing cash
stock
25. Applying services to bounded contexts
Accounting ServiceInventory Service
Billing ServiceOrdering Service
customer
Invoice
balance
order
item
item
stock order
order
item
incoming cash
outgoing cash
stock
AccountingInventory
BillingOrdering
customer
Invoice
balance
order
item
item
stock order
order
item
incoming cash
outgoing cash
stock
27. Sam Newman
“If you’re coming from a monolithic system point of view, you’ll
have to get much better at handling deployment, testing, and
monitoring to unlock the benefits we’ve covered so far. You’ll also
need to think differently about how you scale your systems and
ensure that they are resilient. Don’t also be surprised if things like
distributed transactions or CAP theorem start giving you
headaches, either!”
36. A HashiCorp Project.
https://www.consul.io/
K/V
K/V
K/V
K/V
K/V
Distributed Key/Value Store
http
dns
Client
raft - leader election
gossip - node detection
Node
{
"service": {
"name": "preference",
"tags": ["spring"],
"port": 8000,
"checks": [
{
"script": "/usr/local/bin/check_preference.py",
"interval": "10s"
}
]
}
}
Service Registration
$ dig @127.0.0.1 -p 8600 preference.service.consul SRV
...
;; QUESTION SECTION:
;preference.service.consul. IN SRV
;; ANSWER SECTION:
preference.service.consul. 0 IN SRV 1 1 8000 agent-
one.node.dc1.consul.
;; ADDITIONAL SECTION:
agent-one.node.dc1.consul. 0 IN A 172.20.20.11
Service Query (DNS)
$ curl http://localhost:8500/v1/catalog/service/preference
[{"Node":"agent-
one","Address":"172.20.20.11","ServiceID":"preference",
"ServiceName":"preference","ServiceTags":
["spring"],"ServicePort":8000}]
Service Query (http)
37. Static
Dynamic
Loadbalancer Loadbalancer
MicroService MicroService MicroService MicroService MicroService
Web Front
End
Web Front
End
Web Front
End
Web Front
End
Web Front
End
MicroService MicroService MicroService MicroService MicroService
A
B
Midtier Service Registry
MicroService
register
renew
get registry
eureka
ribbon
https://github.com/Netflix/eureka
https://github.com/Netflix/ribbon
38. Apache ZooKeeper™
synapse - HAProxy based service discovery/routing
nerve - sidecar for service registration
we can’t cover them all …
39. Registration
Embedded In-app registrationSidecar based approach
⊖
• more difficult to take
service lifecycle into
account
⊕
• no impact on the
application
• language agnostic
• easier to control service
registration
⊖
• requires language
specific integration
• will not work with
legacy services
⊕
• deep integration with
insight in the service
lifecycle
Discovery
API basedDNS
⊖
• TTL difficulties
• complex routing
requires tighter
integration
⊕
• legacy integration
⊖
• API integration has
impact on the
application
⊕
• service metadata can be
leveraged for routing
42. Hides partitioning
of microservices
Single point of entry
Client-tailored API
Request aggregation
for performance
Simplifies clients
by aggregation of APIs
Increased complexity
Increased response time
by network hop
54. Continuous Integration
Infrastructure
build
Source Control System
Monolithic Build
single
version tree
/preference-service
/ordering-service
/inventory-service
…
Repository
preference-service-
artefact-311
preference-service-
artefact-311
preference-service-
artefact-311
55. Continuous Integration
Infrastructure
Source Control System
own
version tree
/preference-service
Repository
/ordering-service
Repository
/inventory-service
Repository
MicroService Build
preference-service-
artefact-765
preference-service-
artefact-311
MicroService Build
preference-service-
artefact-459MicroService Build
84. - Correct Functional decomposition is crucial
- reflect it in a organisational structure (💡Conway’s law)
- Getting it right is not guaranteed to be easy
- your aiming for a very high standard in software delivery
- balance the needs (advantages) with the costs (tradeoffs)
- take a simple step at a time
Conclusion
Are they here to stay?
who can tell?
but the monolith is dead