Intro to Microservices

109
Introduction to Microservices Vlad Korolev [email protected]

Transcript of Intro to Microservices

Page 1: Intro to Microservices

Introduction to Microservices

Vlad [email protected]

Page 2: Intro to Microservices

Microservices

2 / 50

Page 3: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 4: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 5: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 6: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 7: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 8: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 9: Intro to Microservices

Microservices

What are the micro services?

Where did they come from?

Core principles

Why should I bother?

Challenges and pitfalls

Good practices

Pro-tips

3 / 50

Page 10: Intro to Microservices

Microservices : what’s that?

4 / 50

Page 11: Intro to Microservices

Microservices : what’s that?

Post continuous delivery SOA

Small independently releasable services, that work together,modeled around a business domain.

5 / 50

Page 12: Intro to Microservices

Microservices : what’s that?

Post continuous delivery SOA

Small independently releasable services, that work together,modeled around a business domain.

5 / 50

Page 13: Intro to Microservices

Prehistoric technology

6 / 50

Page 14: Intro to Microservices

Prehistoric technology

SOA

Domain driven design

Continous delivery

7 / 50

Page 15: Intro to Microservices

Prehistoric technology

SOA

Domain driven design

Continous delivery

7 / 50

Page 16: Intro to Microservices

Prehistoric technology

SOA

Domain driven design

Continous delivery

7 / 50

Page 17: Intro to Microservices

Case study

8 / 50

Page 18: Intro to Microservices

Case study

9 / 50

Page 19: Intro to Microservices

Case study

Catalog

Recommendations / Promotions

Shopping Cart

Search

Orders

RMA

Customer Support

10 / 50

Page 20: Intro to Microservices

Application Composition : Monolith

11 / 50

Page 21: Intro to Microservices

Application Composition : Monolith

Works most of the time

Somewhat scalable

Manageable up to a point

All or nothing updates

Tight coupling

12 / 50

Page 22: Intro to Microservices

SOA

Break up application into set of independent services

Add extra layers

Integration Layer (ESB)Service Layer

Rename existing layers

Frontend → Consumer Interface LayerDatabase → Operational SystemMiddleware → Business Process Layer

13 / 50

Page 23: Intro to Microservices

SOA

Break up application into set of independent services

Add extra layers

Integration Layer (ESB)Service Layer

Rename existing layers

Frontend → Consumer Interface LayerDatabase → Operational SystemMiddleware → Business Process Layer

13 / 50

Page 24: Intro to Microservices

SOA

Break up application into set of independent services

Add extra layers

Integration Layer (ESB)Service Layer

Rename existing layers

Frontend → Consumer Interface LayerDatabase → Operational SystemMiddleware → Business Process Layer

13 / 50

Page 25: Intro to Microservices

Application Composition : SOA

14 / 50

Page 26: Intro to Microservices

Application Composition : SOA

Did well in some organizations

Not so well in others

Reasons for failure

Conway’s LawIgnoring CAP theoremIgnoring Fallacies of distributedcomputing

15 / 50

Page 27: Intro to Microservices

Conway’s Law

16 / 50

Page 28: Intro to Microservices

Conway’s Law

organizations which design systems ... are constrained to producedesigns which are copies of the communication structures of theseorganizations

– M. Conway

17 / 50

Page 29: Intro to Microservices

Conway’s Law

organizations which design systems ... are constrained to producedesigns which are copies of the communication structures of theseorganizations

18 / 50

Page 30: Intro to Microservices

Fallacies of distributedcomputing

19 / 50

Page 31: Intro to Microservices

Fallacies of distributed computing

The network is reliable

Latency is zero

Bandwidth is infinite

The network is secure

Topology doesn’t change

There is one administrator

Transport cost is zero

The network is homogeneous

20 / 50

Page 32: Intro to Microservices

CAP Theorem

21 / 50

Page 33: Intro to Microservices

CAP Theorem

Consistency

Availability

Partitioning tolerance

22 / 50

Page 34: Intro to Microservices

Domain Driven Design

23 / 50

Page 35: Intro to Microservices

Domain Driven Design

Bounded contexts

Draw boundaries around business domains

Do not partition system based on technology

24 / 50

Page 36: Intro to Microservices

Domain Driven Design

Bounded contexts

Draw boundaries around business domains

Do not partition system based on technology

24 / 50

Page 37: Intro to Microservices

Domain Driven Design

Bounded contexts

Draw boundaries around business domains

Do not partition system based on technology

24 / 50

Page 38: Intro to Microservices

Application Composition :Microservices

25 / 50

Page 39: Intro to Microservices

Application Composition : Microservices

26 / 50

Page 40: Intro to Microservices

Application Composition : Microservices

Modeled around business domain

Autonomous

Hide implementation detail

Decentralized

Isolate the failure

Highly observable

Culture of automation

27 / 50

Page 41: Intro to Microservices

Microservices : Good Parts

28 / 50

Page 42: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 43: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 44: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 45: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 46: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 47: Intro to Microservices

Microservices : Good Parts

Small and focused

Independent

Loosely coupled

Allow try and pilot new tech

Firm module boundaries

Decentralized data

29 / 50

Page 48: Intro to Microservices

Why bother?

30 / 50

Page 49: Intro to Microservices

Why bother?

Latest Buzzword

All the cool kids are doing it

Probably, not good reasons

31 / 50

Page 50: Intro to Microservices

Why bother?

Latest Buzzword

All the cool kids are doing it

Probably, not good reasons

31 / 50

Page 51: Intro to Microservices

Why bother?

Latest Buzzword

All the cool kids are doing it

Probably, not good reasons

31 / 50

Page 52: Intro to Microservices

Why bother?

Faster dev cycles

Team autonomy

Smoother scaling

32 / 50

Page 53: Intro to Microservices

Why bother?

Faster dev cycles

Team autonomy

Smoother scaling

32 / 50

Page 54: Intro to Microservices

Why bother?

Faster dev cycles

Team autonomy

Smoother scaling

32 / 50

Page 55: Intro to Microservices

Challenges

Complex runtime

Distributed deployment

Extensive communication

Handling failures

33 / 50

Page 56: Intro to Microservices

Challenges

Complex runtime

Distributed deployment

Extensive communication

Handling failures

33 / 50

Page 57: Intro to Microservices

Challenges

Complex runtime

Distributed deployment

Extensive communication

Handling failures

33 / 50

Page 58: Intro to Microservices

Challenges

Complex runtime

Distributed deployment

Extensive communication

Handling failures

33 / 50

Page 59: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 60: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 61: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 62: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fast

Bulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 63: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 64: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 65: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 66: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 67: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 68: Intro to Microservices

Good practices

Humane registries

Team composition

Isolate failures

Fail fastBulkheading

Standardize communications

REST or Message Queues

Robust Service Discovery

Consider something like Consul / Zookeeper / ETCd

Monitor everything

34 / 50

Page 69: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract TestsConsumer driven development

35 / 50

Page 70: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract TestsConsumer driven development

35 / 50

Page 71: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract TestsConsumer driven development

35 / 50

Page 72: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract TestsConsumer driven development

35 / 50

Page 73: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract Tests

Consumer driven development

35 / 50

Page 74: Intro to Microservices

Deployments

Avoid huge build jobs

One service per host

Host is either physical host, VM or container

Test

Contract TestsConsumer driven development

35 / 50

Page 75: Intro to Microservices

Potential pitfalls

Incorrect partitioning

Distributed point of failure

Misunderstanding your network

36 / 50

Page 76: Intro to Microservices

Potential pitfalls

Incorrect partitioning

Distributed point of failure

Misunderstanding your network

36 / 50

Page 77: Intro to Microservices

Potential pitfalls

Incorrect partitioning

Distributed point of failure

Misunderstanding your network

36 / 50

Page 78: Intro to Microservices

Refactoring to Microservices

Strangler pattern

Use static analysis tool to find natural boundaries

Shadow systems

37 / 50

Page 79: Intro to Microservices

Refactoring to Microservices

Strangler pattern

Use static analysis tool to find natural boundaries

Shadow systems

37 / 50

Page 80: Intro to Microservices

Refactoring to Microservices

Strangler pattern

Use static analysis tool to find natural boundaries

Shadow systems

37 / 50

Page 81: Intro to Microservices

Personal Experiences

38 / 50

Page 82: Intro to Microservices

Monitor Everything

Exception catchers

Centralized log collections

Synthetic transactions

39 / 50

Page 83: Intro to Microservices

Monitor Everything

Exception catchers

Centralized log collections

Synthetic transactions

39 / 50

Page 84: Intro to Microservices

Monitor Everything

Exception catchers

Centralized log collections

Synthetic transactions

39 / 50

Page 85: Intro to Microservices

Monitor Everything

Exception catchers

Centralized log collections

Synthetic transactions

39 / 50

Page 86: Intro to Microservices

Understand your networking

Microservices increase network chatter

More failures with UDP based protocols (DNS, discovery)

More hiccups with TCP based protocols

Run out of sockets

Decrease TCP timeouts, seconds instead of minutes

Batch the transactions.

But can’t have batching service

40 / 50

Page 87: Intro to Microservices

Understand your networking

Microservices increase network chatter

More failures with UDP based protocols (DNS, discovery)

More hiccups with TCP based protocols

Run out of sockets

Decrease TCP timeouts, seconds instead of minutes

Batch the transactions.

But can’t have batching service

40 / 50

Page 88: Intro to Microservices

Understand your networking

Microservices increase network chatter

More failures with UDP based protocols (DNS, discovery)

More hiccups with TCP based protocols

Run out of sockets

Decrease TCP timeouts, seconds instead of minutes

Batch the transactions.

But can’t have batching service

40 / 50

Page 89: Intro to Microservices

Understand your networking

Microservices increase network chatter

More failures with UDP based protocols (DNS, discovery)

More hiccups with TCP based protocols

Run out of sockets

Decrease TCP timeouts, seconds instead of minutes

Batch the transactions.

But can’t have batching service

40 / 50

Page 90: Intro to Microservices

Understand your networking

Microservices increase network chatter

More failures with UDP based protocols (DNS, discovery)

More hiccups with TCP based protocols

Run out of sockets

Decrease TCP timeouts, seconds instead of minutes

Batch the transactions.

But can’t have batching service

40 / 50

Page 91: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 92: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 93: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 94: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 95: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 96: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devs

https://github.com/realestate-com-au/pact

41 / 50

Page 97: Intro to Microservices

Robust CI/CD pipeline

1 Service = 1 Repo = 1 Build Job = 1 Artifact

Instantaneous deployments

Pre-build AMis, Containers

Test coverage

Consumer Driven Tests

Avoid integration tests written by service devshttps://github.com/realestate-com-au/pact

41 / 50

Page 98: Intro to Microservices

Consider using client side load balancing

Service side load balancers create point of failure

Hard to deploy and manage HW load balancers

Problem of running out of sockets

Netflix Ribbon Libraryhttps://github.com/Netflix/ribbon/wiki/Working-with-load-balancers

42 / 50

Page 99: Intro to Microservices

Consider using client side load balancing

Service side load balancers create point of failure

Hard to deploy and manage HW load balancers

Problem of running out of sockets

Netflix Ribbon Libraryhttps://github.com/Netflix/ribbon/wiki/Working-with-load-balancers

42 / 50

Page 100: Intro to Microservices

Consider using client side load balancing

Service side load balancers create point of failure

Hard to deploy and manage HW load balancers

Problem of running out of sockets

Netflix Ribbon Libraryhttps://github.com/Netflix/ribbon/wiki/Working-with-load-balancers

42 / 50

Page 101: Intro to Microservices

Consider using client side load balancing

Service side load balancers create point of failure

Hard to deploy and manage HW load balancers

Problem of running out of sockets

Netflix Ribbon Libraryhttps://github.com/Netflix/ribbon/wiki/Working-with-load-balancers

42 / 50

Page 102: Intro to Microservices

Never make MapReduce pipeline talk to service outside ofyour cluster

43 / 50

Page 103: Intro to Microservices

Never make MapReduce pipeline talk to service outside ofyour cluster

44 / 50

Page 104: Intro to Microservices

Further resources

45 / 50

Page 105: Intro to Microservices

Further resources

46 / 50

Page 106: Intro to Microservices

Further resources

47 / 50

Page 107: Intro to Microservices

Further resources

Toughtworks Youtube channel

48 / 50

Page 108: Intro to Microservices

???

49 / 50

Page 109: Intro to Microservices

Thank you

50 / 50