code freeze 2018: there is no such thing as a microservice!

71
@crichardson There is no such thing as a microservice! Chris Richardson Founder of Eventuate.io Founder of the original CloudFoundry.com Author of POJOs in Action @crichardson [email protected] http://microservices.io http://eventuate.io http://plainoldobjects.com Copyright © 2017. Chris Richardson Consulting, Inc. All rights reserved

Upload: chris-richardson

Post on 28-Jan-2018

43 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

There is no such thing as a microservice!

Chris Richardson

Founder of Eventuate.io Founder of the original CloudFoundry.com Author of POJOs in Action

@crichardson [email protected] http://microservices.io http://eventuate.io http://plainoldobjects.com

Copyright © 2017. Chris Richardson Consulting, Inc. All rights reserved

Page 2: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Presentation goal

Define the Microservice Architecture

as an architectural style

Explain what that means and why it

matters

Page 3: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

About Chris

Page 4: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

About Chris

Consultant and trainer focusing on modern

application architectures including microservices

(http://www.chrisrichardson.net/)

Page 5: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

About Chris

Founder of a startup that is creating an open-source/SaaS platform

that simplifies the development of transactional microservices

(http://eventuate.io)

Page 6: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

About Chris

http://learnmicroservices.io

40% off ctwcodefreeze18

Page 7: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Agenda

A brief refresher on software architecture

From monolith to microservices

Microservices != silver bullet

Applying the microservice pattern language

Page 8: Code Freeze 2018: There is no such thing as a microservice!

About software architecture

“The software architecture of a computing system is the set of structures needed to reason about the system, which comprise software elements, relations among

them, and properties of both.”

Documenting Software Architectures, Bass et al

Page 9: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Architecture =

(elements, relations, properties)

Page 10: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Architecture =

Boxes and lines 😄

Page 11: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Architecture is multi-dimensional e.g. Structural, electrical, plumbing,

mechanical⇒

Described by multiple views

View = (elements, relations, properties)

Page 12: Code Freeze 2018: There is no such thing as a microservice!

4+1 view model

Logical View

Process View

Deployment View

Implementation View

Scenarios

Page 13: Code Freeze 2018: There is no such thing as a microservice!

4+1 Logical view

Logical View

Process View

Deployment View

Implementation View

Scenarios

Elements: classes and packages Relations: inheritance, associations, …

Page 14: Code Freeze 2018: There is no such thing as a microservice!

4+1 Implementation view

Logical View

Process View

Deployment View

Implementation View

Scenarios

Elements: modules and components Relations: dependencies

Page 15: Code Freeze 2018: There is no such thing as a microservice!

4+1 Process view

Logical View

Process View

Deployment View

Implementation View

ScenariosElements: processes Relations: IPC

Page 16: Code Freeze 2018: There is no such thing as a microservice!

4+1 Deployment view

Logical View

Process View

Deployment View

Implementation View

ScenariosElements: “machines” Relations: networking

Page 17: Code Freeze 2018: There is no such thing as a microservice!

4+1 Scenarios

Logical View

Process View

Deployment View

Implementation View

ScenariosDerived from use cases/stories

Animate the views

Page 18: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

""… An architectural style determines the vocabulary of components and

connectors that can be used in instances of that style, together with a set of constraints on how they can be

combined….. ”” David Garlan and Mary Shaw, An Introduction to Software Architecture

Page 19: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Layered architectural styleLayer N

Layer N - 1

Layer N - 2

Well defined responsibilities

Constrained dependencies

Uses Uses

UsesUses

Page 20: Code Freeze 2018: There is no such thing as a microservice!

The role of architecture

Requirements =

Functional requirements +

Non-functional requirements (-ilities)

Domain knowledge

Architecture

Page 21: Code Freeze 2018: There is no such thing as a microservice!

Important -ilitiesMaintainability

Testability

Deployability

Evolvability

Scalability

Security

Reliability

https://en.wikipedia.org/wiki/Non-functional_requirement

Development velocity

Sunday afternoon 😀

Page 22: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Businesses must innovate faster ⇒

Build better software faster

Page 23: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Reducing lead time

Increasing deployment frequency

Page 24: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Modern software development: moving fast and not breaking things!

46x

440x

24x

5x lower

Amazon: ~0.001%

Netflix: 16 minutes

Page 25: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Modern software development

Architecture:

Process:

Small, autonomous teams

???

DevOps/Continuous delivery/deployment

Organization:

Page 26: Code Freeze 2018: There is no such thing as a microservice!

Agenda

A brief refresher on software architecture

From monolith to microservices

Microservices != silver bullet

Applying the microservice pattern language

Page 27: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Tomcat/App. Server

Traditional: Monolithic architecture

Browser/Client

WAR/EAR

MySQL Database

Review Management

Catalog Management

Recommendation Management

StoreFrontUI

Order Management

HTMLREST/JSON

Logical viewImplementation view

Page 28: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

The monolithic architecture is an architectural style

that structures the application as a single executable

component

Implementation view

Page 29: Code Freeze 2018: There is no such thing as a microservice!

-ilities of small monoliths

Maintainability

Testability

Deployability

https://en.wikipedia.org/wiki/Non-functional_requirement

😄

Page 30: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

But successful applications keep growing….

Development Team Application

Page 31: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

… and growing

Development Team A

ApplicationDevelopment Team B

Development Team C

Page 32: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Eventually:

agile development

and deployment becomes

impossible

=

monolithic hell

Page 33: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Technology stack becomes increasingly obsolete

BUT A rewrite is not feasible

Page 34: Code Freeze 2018: There is no such thing as a microservice!

-ilities of large monoliths

Maintainability

Testability

Deployability

https://en.wikipedia.org/wiki/Non-functional_requirement

😭

Page 35: Code Freeze 2018: There is no such thing as a microservice!

The microservice architecture is an architectural style

that structures an application as a

set of loosely coupled, services organized around

business capabilities

Page 36: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Application

Service = business capabilityAcme, Inc

Order Taking

Inventory management

Delivery management

Business Capability = something a business does to deliver value

Order Service

Inventory Management

Service

Delivery Management

Service … Service

Page 37: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Service = independently deployable component

CommandQuery

API

EventPublisher

EventSubscriber

APIClient

Consumer facing Implementation

Synchronous: REST, gRPC, …Asynchronous: Command/Reply, Notification

Service database

EventsEvents

Synchronous: REST, gRPC, …

Asynchronous: Command/Reply, Notification

Data owned by the service

Data replicated from elsewhereSLA

Page 38: Code Freeze 2018: There is no such thing as a microservice!

Service size is secondary

microservice architecture

Page 39: Code Freeze 2018: There is no such thing as a microservice!

Service:

Meaningful business functionality

Developed by a small team

Minimal lead time/high deployment frequency

Page 40: Code Freeze 2018: There is no such thing as a microservice!

Microservices =

Microservice architecture =

Application architecture ⇒

No such thing as a microservice

Page 41: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Browser

Mobile Device

Content Router

API Gateway

Catalog Service

Review Service

Order Service

… Service

Catalog Database

Review Database

Order Database

… Database

HTTP /HTML

REST

REST

Browse & Search WebApp

Product Detail WebApp

….

Supplier Inbound Gateway

Catalog update messages

Supplier System

Page 42: Code Freeze 2018: There is no such thing as a microservice!

-ilities of a microservice architecture

Maintainability

Testability

Deployability

https://en.wikipedia.org/wiki/Non-functional_requirement

😄

Page 43: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Microservices ⇒

DevOps/Continuous delivery/deployment of large/complex applications

Page 44: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Process: Continuous delivery/deployment

Organization:Small, agile, autonomous,

cross functional teams

Architecture: Microservice architecture

Enables

Enables Enables

SuccessfulSoftware

Development

Services improve testability

and deployability

Teams own services

Page 45: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Microservices ⇒ evolve the technology stack

Pick a new technology when

Writing a new service

Making major changes to an existing service

Let’s you experiment and fail safely

Page 46: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Agenda

A brief refresher on software architecture

From monolith to microservices

Microservices != silver bullet

Applying the microservice pattern language

Page 47: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

No silver bullets

http://en.wikipedia.org/wiki/Fred_Brooks

Page 48: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Drawbacks of microservices

Complexity

Development: IPC, partial failure, distributed data Testing: Integration, end to end, …Deployment …

Page 49: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Are microservices a good fit for my application?

Page 50: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Do I have the pre-requisites in place:

automated testing automated provisioning ….. ?

Page 51: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

When using microservices:How to decompose an application into services?

How to deploy an application’s services?How to handle cross cutting concerns?

Which communication mechanisms to use?

How do external clients communicate with the services?

How does a client discover the network location of a service instance?

How to prevent a network or service failure from cascading to other services?

How to maintain data consistency and implement queries?

How to make testing easier?

How to understand the behavior of an application and troubleshoot problems?

How to implement a UI screen or page that displays data from multiple services?

Page 52: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

It depends!

Page 53: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Microservice pattern language =

collection of patterns that solve these

architecture, design, development and operational problems

Page 54: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

What’s a pattern?

Reusable solution to a problem

occurring in a particular context

Page 55: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

The structure of a pattern encourages objectivity

Resulting context

aka the situation

Name

Context

Problem

Related patterns

(conflicting) issues etc to address Forces

Solution Benefits

Drawbacks

Issues to resolve

Alternatives

Solutions to issues

Page 56: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Microservices pattern language: http://microservices.io

Page 57: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Agenda

A brief refresher on software architecture

From monolith to microservices

Microservices != silver bullet

Applying the microservice pattern language

Page 58: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

The pattern language guides you when developing an architecture

What architectural decisions you must make

For each decision:

Available options

Trade-offs of each option

Page 59: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Key patterns

Page 60: Code Freeze 2018: There is no such thing as a microservice!

Issue: What’s the deployment architecture?

Forces

Maintainability

Deployability

Testability

Monolithic architecture

Microservice architecture

Single deployable/executable OR

Tightly coupled services

Multiple loosely coupled services

Page 61: Code Freeze 2018: There is no such thing as a microservice!

Issue: How to decompose an application into services?

Forces

Stability

Cohesive

Loosely coupled

Not too large

Decompose bybusiness capability

Decompose bysubdomain

Organize around business capabilities

Organize around DDD subdomains

Page 62: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: how to maintain data consistency?Context

• Each service has its own database

• Data is private to a service

Forces

Transactional data consistency must be maintained across multiple services

2PC is not an option

Page 63: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: how to perform queries?

CQRS

Context

Each service has its own database

Forces

Queries must join data from multiple services

Data is private to a serviceMaintain query views by subscribing to events

API Composition

Page 64: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

The rest are generic technical architecture patterns

= Undifferentiated heavy lifting!

Page 65: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: How do services communicate?

Messaging Remote ProcedureInvocation

Domain-specific

Forces

Services must communicate

Usually processes on different machines

Page 66: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: How to handle cross cutting concerns?

Microservice Chassis

Forces

Every service must implement logging; externalize configuration; health check endpoint; metrics; …

Page 67: Code Freeze 2018: There is no such thing as a microservice!

Issue: How to deploy an application’s services?

Multiple Services per host

Single Service per Host

Service-per-Container

Service-per-VM

Serverless deployment

Service deployment platform

Forces

Multiple languages

Isolated

Constrained

Monitor-able

Reliable

Efficient

Page 68: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: How to discover a service instance’s network location?

Client-side discovery

Server-side discovery

Service registry

Self registration

3rd party registration

Forces

Client needs IP address of service instance

Dynamic IP addresses

Dynamically provisioned instances

Page 69: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Issue: how to monitor the behavior of your application?

Exception tracking

Distributed tracing

Audit logging Application metrics

Log aggregation

Health check API

Page 70: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

Summary

The goal of architecture is to satisfy non-functional requirements

For continuous delivery/deployment use the appropriate architectural style

Small applications ⇒ Monolithic architecture

Complex applications ⇒ Microservice architecture

Use the pattern language to guide your decision making

Page 71: Code Freeze 2018: There is no such thing as a microservice!

@crichardson

@crichardson [email protected]

http://learnmicroservices.io

Thank you!

40% off ctwcodefreeze18