practical microservices - ndc 2014

179
PRACTICAL CONSIDERATIONS FOR MICRO SERVICES Sam Newman NDC London, December 2014 1

Upload: sam-newman

Post on 08-Jul-2015

3.970 views

Category:

Technology


5 download

DESCRIPTION

Presented at NDC London, December 2014 Microservice architectures can lead to easier to change, more maintainable systems which can be more secure, performant and stable than previous designs. But what are the practical concerns associated with running more fine-grained systems, and what are the new things you’ll need to know if you want to embrace the power of smaller services without the new sources of complexity making your life a nightmare? This talk will delve deeper into the characteristics of well-behaved services, and will define some clear principles your services should follow. It will also discuss in more depth some of the challenges associated with managing and monitoring more complex distributed systems. We’ll discuss how you can design services to be more fault-tolerant, what technologies may exist in your own platform to get you started. We’ll end by giving some pointers as to when you should consider microservice architectures, and how you should go about introducing them in your own organisation.

TRANSCRIPT

  • PRACTICAL CONSIDERATIONS FOR MICRO SERVICESSam Newman NDC London, December 2014

    1

  • 14 PRACTICAL TIPS FOR MICROSERVICESSam Newman NDC London, December 2014

    2

  • YOU WONT BELIEVE WHAT THEY DO WITH MICROSERVICES IN THIS TALK!Sam Newman NDC London, December 2014

    3

  • SEE WHAT JENNIFER LAWRENCE THINKS ABOUT DISTRIBUTED SYSTEMS!Sam Newman NDC London, December 2014

    4

  • @samnewman#ndclondon

    Accounts

    Returns

    Invoicing

    Shipping

    Inventory

    Customer Service

  • @samnewman#ndclondon

    Accounts

    Returns

    Invoicing

    Shipping

    Inventory

    Customer Service

    Small

  • @samnewman#ndclondon

    Accounts

    Returns

    Invoicing

    Shipping

    Inventory

    Customer Service

    Small

    Modelled Around Business Domain

  • @samnewman#ndclondon

    Accounts

    Returns

    Invoicing

    Shipping

    Inventory

    Customer Service

    Small

    Modelled Around Business Domain

    Autonomous

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    V1

  • @samnewman#ndclondon

    V2

  • @samnewman#ndclondon

    Go

    Java

    NodeJS

    Ruby

  • @samnewman#ndclondon

    Go

    NodeJS

    Ruby

    Clojure!

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Where To Standardise?

  • @samnewman#ndclondon 2013 Electronic Arts Inc.

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Interfaces

  • @samnewman#ndclondon

    Interfaces

    Monitoring

  • @samnewman#ndclondon

    Interfaces

    Monitoring

    Deployment & Testing

  • @samnewman#ndclondon

    Architectural Safety

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Free For All

  • @samnewman#ndclondon

    Standardisation

    Free For All

  • @samnewman#ndclondon

    Standardisation

    Free For All

    TIP 1 / 14: Standardise in the gaps between services - be exible about what happens inside the boxes

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon https://www.ickr.com/photos/garrymsmith/6108841070

  • @samnewman#ndclondon

    Autonomy

    Communication

  • @samnewman#ndclondon

    Team Ownership

  • @samnewman#ndclondon

    Team Ownership

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???

  • @samnewman#ndclondon

    Trusted Committer / Roving Custodian

    ???TIP 2 / 14: Have a clear custodian model!

  • @samnewman#ndclondon

    Interfaces

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Coupling Is Bad

  • @samnewman#ndclondon

    Data Oriented Procedure Oriented Document Oriented

    Resource Oriented

    Integration Styles An Evolutionary View

  • @samnewman#ndclondon

    Data Oriented Procedure Oriented Document Oriented

    Resource Oriented

    Integration Styles An Evolutionary View

  • @samnewman#ndclondon

    Data Oriented Procedure Oriented Document Oriented

    Resource Oriented

    Integration Styles An Evolutionary View

    TIP 3 / 14: Be careful of RPC-mechanisms/shared serialisation protocols to avoid coupling

  • @samnewman#ndclondon

    Database

  • @samnewman#ndclondon

    Database

  • @samnewman#ndclondon

    Database

  • @samnewman#ndclondon

    Database

  • @samnewman#ndclondon

    DatabaseDatabase

  • @samnewman#ndclondon

    DatabaseDatabase

  • @samnewman#ndclondon

    DatabaseDatabase

  • @samnewman#ndclondon

    Database Database

  • @samnewman#ndclondon

    Database Database

  • @samnewman#ndclondon

    Database Database

    TIP 4 / 14: Separate the databases before separating services

  • @samnewman#ndclondon

    The Customer Is Always Right

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    TIP 5 / 14: Adopt a consumer rst approach

  • @samnewman#ndclondon

    Monitoring

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    http://www.flickr.com/photos/kalexanderson/5421517469/

  • @samnewman#ndclondon

    http://www.flickr.com/photos/kalexanderson/5421517469/

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    ???

  • @samnewman#ndclondon

    You have to get *much* better at monitoring

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    You are not a badass if you use an SSH Multiplexer

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Response TimeResponse Time

    Response Time

  • @samnewman#ndclondon

    Response TimeResponse Time

    Response Time

  • @samnewman#ndclondon

    Response TimeResponse Time

    Response Time

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    TIP 6 / 14: Capture metrics, and logs, for each node, and aggregate them to get a rolled up picture

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    TIP 7 / 14: Use synthetic transactions to test production systems

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    ID: 123

  • @samnewman#ndclondon

    ID: 123

    ID: 123

    ID: 123

  • @samnewman#ndclondon

    ID: 123

    ID: 123

    ID: 123

    TIP 8 / 14: Use correlation IDs to track down nasty bugs

  • @samnewman#ndclondon

    Deployment

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    !

  • @samnewman#ndclondon

    !

    !

  • @samnewman#ndclondon

    !

    !

    !

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    TIP 9 / 14: Abstract out underlying platform dierences to provide a uniform deployment mechanism

  • @samnewman#ndclondon

    InventoryAccounts

    Returns

    Invoicing

    Shipping

    Customer Service

  • @samnewman#ndclondon

    InventoryAccounts

    Returns

    Invoicing

    Shipping

    Customer Service

    Inventory

  • @samnewman#ndclondon

    InventoryAccounts

    Returns

    Invoicing

    Shipping

    Customer Service

    Inventory

  • @samnewman#ndclondon

    Inventory Accounts

    Mountebank http://www.mbtest.org

  • @samnewman#ndclondon

    InventoryAccounts

    Stub

    Mountebank http://www.mbtest.org

  • @samnewman#ndclondon

    Shipping

    InventoryAccounts

    Returns

    Invoicing

    Customer Service

  • @samnewman#ndclondon

    Shipping

    InventoryAccounts

    Returns

    Invoicing

    Customer Service

  • @samnewman#ndclondon

    Shipping

    InventoryAccounts

    Returns

    Invoicing

    Customer Service

  • @samnewman#ndclondon

    Shipping

    InventoryAccounts

    Returns

    Invoicing

    Customer Service

  • @samnewman#ndclondon

    Shipping

    InventoryAccounts

    Returns

    Invoicing

    Customer Service

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    Browsers

  • @samnewman#ndclondon

    Timing

    Browsers

  • @samnewman#ndclondon

    Provisioning of Environments

    Timing

    Browsers

  • @samnewman#ndclondon

    Provisioning of Environments

    Networks

    Timing

    Browsers

  • @samnewman#ndclondon

    Deployment

    Provisioning of Environments

    Networks

    Timing

    Browsers

  • @samnewman#ndclondon

    Deployment

    Provisioning of Environments

    Networks

    Timing

    Browsers Diagnosis

  • @samnewman#ndclondon

    Shipping Inventory

    CONSUMER-DRIVEN CONTRACTS

  • @samnewman#ndclondon

    Expectations

    Shipping Inventory

    CONSUMER-DRIVEN CONTRACTS

  • @samnewman#ndclondon

    Expectations

    Shipping Inventory

    CONSUMER-DRIVEN CONTRACTS

  • @samnewman#ndclondon

    Expectations

    Prod

    Shipping Inventory

    CONSUMER-DRIVEN CONTRACTS

  • @samnewman#ndclondon

    Expectations

    Prod

    Shipping Inventory

    CONSUMER-DRIVEN CONTRACTS

  • @samnewman#ndclondon

  • @samnewman#ndclondon

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

  • @samnewman#ndclondon

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

    TIP 10 / 14: Consumer Driven Tests to catch breaking changes

  • Pending Prod

  • Pending Prod

  • Pending Prod

  • Pending Prod

  • Pending Prod

  • Pending Prod

    TIP 11 / 14: Dont let changes build up - release as soon as you can, and preferably one at a time!

  • @samnewman#ndclondon

    Architectural Safety

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    http://www.flickr.com/photos/louish/5611657857/

  • @samnewman#ndclondon

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

    Connection Pool

  • @samnewman#ndclondon

    Connection Pool

    Connection Pool

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    TIP 12 / 14: Use timeouts, circuit breakers and bulk-heads to avoid cascading failure

  • @samnewman#ndclondon

    Special Service Behaviour

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

    Downstream

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

    Downstream

    Metrics

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

    Downstream

    Metrics

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

    Downstream

    Metrics

  • @samnewman#ndclondon

    Special Service Behaviour

    Integration

    Downstream

    Metrics TIP 13 / 14: Consider Service Templates to make it easy to do the right thing!

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

  • @samnewman#ndclondon

    ChoiceOpportunity

  • @samnewman#ndclondon

    ChoiceOpportunity

    Complexity

  • @samnewman#ndclondon

    ChoiceOpportunity

    ComplexityMonitoring

    Deployment

    SafetyIntegration

  • @samnewman#ndclondon

    ChoiceOpportunity

    ComplexityMonitoring

    Deployment

    SafetyIntegration

    TIP 14 / 14: Find your own balance

  • 62

    Sam Newman

    Building MicroservicesDESIGNING FINE-GRAINED SYSTEMS

  • @samnewman#ndclondon

    Designing For Rapid Release

    500 West Madison500 West Madison

  • @samnewman#ndclondon

    From Macro To Micro

    Designing For Rapid Release

    500 West Madison500 West Madison

  • @samnewman#ndclondon

    http://lanyrd.com/prole/samnewman/

    From Macro To Micro

    Designing For Rapid Release

    500 West Madison500 West Madison

  • Any questions: @samnewman

    [email protected]

    THANKS!