Top Banner
Microservices – All is Small, All is Well? Eberhard Wolff Freelancer
50
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Microservice - All is Small, All is Well?

Microservices – All is Small, All is Well?

Eberhard Wolff Freelancer

Page 2: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Leseprobe: http://bit.ly/CD-Buch

Page 3: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservice Definition

Page 4: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservices: Definition •  Small •  Independent deployment units •  i.e. processes / VM •  Including GUI

•  Any technology •  Any infrastructure

Micro Service

Server

Micro Service

Server

Page 5: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Components Collaborate

Micro- service

Micro- service

Link

Data Replication

REST Messaging

Page 6: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Online Shop

Order

Catalog

Search

Billing

Customer

HTML / HTTP

Page 7: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservice to scale Agile

Page 8: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Define architecture to

limit communication

Page 9: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservice Conway’s Law

Page 10: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Conway‘s Law

Architecture copies

communication structures of the organization

Page 11: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Order Billing Search Catalog

Order Catalog Search Billing

Team can deploy without integration Changes can be deployed independently & quickly

Strong & enforced modularization

Technology stack per Microservice One or many Microservices per Team

Synergy Microservices / Conway’s Law

Page 12: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

One team can build and

deploy features independently!

Page 13: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Team must be responsible for a sensible set

of functionality

Page 14: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservice Bounded Context

Page 15: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

DDD •  Domain Driven Design •  By Eric Evans

•  UBIQUITOUS LANGUAGE •  Code / database / user should use

the same terms for the domain model

Page 16: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Bounded Context •  Domain model is only valid for one

context

•  There is no universal data model! •  See all failed SOA attempts

Page 17: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Order Shipping Billing

Customer

Loyalty program #

Customer

Shipping address

Customer

Credit Card #

Page 18: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Bounded Context & Microservice

•  Microservice = Bounded Context

•  Changes: local •  Even for data model •  Independent development

•  Relationship = team collaboration

Page 19: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Sustainable Development

Page 20: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Monoliths •  Architecture rot •  …not maintainable any more •  …and can’t be rewritten / replaced

Page 21: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Microservices •  Distributed system of small units •  Architecture violations harder

•  Small units •  Easy to replace

Page 22: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Free choice of technology

Page 23: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Online Shop

Elasticsearch

Spring Batch Oracle

Spring MVC MongoDB

Order

Catalog

Search

Billing

Page 24: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Free Choice of Technology •  Use the best tool for the job

•  Very hard with a monolith

•  Option

•  Can increase motivation

Page 25: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Refactoring & Code Reuse

Page 26: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Code Reuse •  Reuse across technology stacks hard •  Code dependencies are evil! •  Deployment dependency •  No more independent deployment •  Update hell

•  Avoid code reuse! •  Or make it Open Source projects (Netflix) •  Service reuse is fine

Page 27: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Code Reuseis an issue, not a goal

Page 28: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Global Refactorings? •  Move code from service to service •  Might be a port to a different

language •  Separate in a new service? •  More services = more complex

•  Hard

Page 29: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Functional Architecture •  Teams should be independent •  i.e. one team = one functionality •  Otherwise: Coordination hard

•  Functional architecture much more important

Page 30: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Refactoring & Code Reuse

Individual Technology Stacks

Page 31: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Refactoring hard

Functional architecture much

more important

Page 32: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Need to get architecture

right first time

Architecture evolves

Page 33: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Start BIG •  Won’t have too much code at the

start anyway •  Refactoring easier •  Can build architecture as you go

•  Let the functional architecture grow!

Page 34: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Distributed System

Page 35: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

1st Law of Distributed Objects •  Don’t Distribute Your Objects! •  Too much remote communication &

overhead •  Lesson learned from CORBA etc •  Microservice should include a GUI

•  http://martinfowler.com/bliki/FirstLaw.html

Page 36: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Request

Response

Processing

Latency Round Trip: 0,2-0,5 ms = 600.000-1.500.000 instructions@3GHz

Page 37: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

1st Law of Distributed Objects & Microservices

•  Small Microservices mean a lot of communication

•  Violate the 1st Law •  Seems to work, though

•  http://martinfowler.com/articles/distributed-objects-microservices.html

Page 38: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Too small = too much

communication

Page 39: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Resilience •  Failures must not propagate •  Timeouts •  Bulkheads •  Circuit Breaker •  Michael T. Nygard: Release It! •  Implementation: Hystrix (Netflix) •  More robust than monoliths!

Page 40: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Authentication & Authorization •  Centralized authentication •  Service must authorize user •  More complex than monolith

•  E.g. OAuth2

Page 41: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Deploy & Operate?

Page 42: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Component Model •  No restriction on language etc •  Individual processes •  + infrastructure (database etc) •  JARs, WARs, EARs: No good fit

•  Standardized Monitoring •  Standardized Logging

Page 43: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Possible Component Models •  Virtual machine

•  Docker container

•  Installable software (RPM, deb) •  + deployment / config scripts

Page 44: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Operation •  Common standards must be

enforced •  Templates simplify creating new

Microservices •  …avoid too large Microservices •  …and support common standards

Page 45: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Conclusion

Page 46: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Conclusion: Microservices •  Microservices are a new way of

modularization •  More technological freedom •  Architecture to enable scaling agile •  Easier, faster and less risky

deployment

Page 47: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Issues •  Refactoring and reuse hard

•  Distributed systems

•  More sources of failures

Page 48: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Use If… •  Time to market is important •  Sustained development speed •  Large enough project

Page 49: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Don’t Use If… •  Infrastructure complexity cannot be

handled •  Architectural complexity cannot be

handled

Page 50: Microservice - All is Small, All is Well?

Eberhard Wolff - @ewolff

Thank You!