patterns & practices of microservices

Download Patterns & Practices of Microservices

Post on 10-Jan-2017

156 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

  • PATTERNS & P

    RACTICES

    MICROSERVICES

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server

    ~4 YEARS

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    ~3 YEARS

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Hot

    Cold

    Database Server

    ~2 YEARS

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Hot

    Cold

    GLB / DNS

    Reporting Database Server

    ~2 YEARS

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Reporting Database Server

    Hot

    Hot

    Database Server

    GLB / DNS

    ~2 YEARS

  • X18

    x5

    ~2 YEARS

  • ~2 YEARS

  • x2

    2 YEARS

  • W E S L E Y R E I S Z

    San Francisco / London / New York

    CHAIR QCON

  • Loosely coupled Service Oriented Architecture with Bounded Contexts

    -Adrian Cockcroft, Microservices Thoughtleader

    IF EVER

    Y SERV

    ICE HAS

    TO BE

    UPDATE

    D AT TH

    E SAME

    TIME

    ITS NO

    T LOOSE

    LY COUP

    LED

    IF YOU HA

    VE TO KNO

    W TOO

    MUCH ABO

    UT SURRO

    UNDING

    SERVICES

    YOU DON

    T HAVE A

    BOUNDED C

    ONTEXT. S

    EE THE

    DOMAIN DR

    IVEN DES

    IGN BOOK

    BY ERIC E

    VANS.

  • Why Microservices?

  • CONS

    PROS

    Monitoring/Logging becomes more important than ever.

    You trade code simplicity for operational complexity.

    Easy to chase the latest shiny technology / mix new languages & tech in.

    Another dimension to scale the application.

    Easier to have different services usedata persistence most appropriate for the use case.

    Easier to reason about moving applications to the cloud.

    Easier to have a developer understandthe portion of the system and contribute

    Easier to test & deploy a single service.

    Cascading failures can cause problems.

    Orchestration can become complex

  • FIRST PRINCIPLES DevOps Culture,

    Evolutionary Architecture, Scale Cube & CAP Theorem

    MICROSERVICESPATTERNS & PRACTICES

    PATTERNS & PRACTICESTechnical, Operational, Cultural

  • DEVOPS CULTURE IS A MUST

    Rapid provisioning

    Basic monitoring

    Rapid Application Deployment

    http://martinfowler.com/bliki/MicroservicePrerequisites.html

  • Signing up for Microservices is signing up for evolutionary architecture. Theres no point where youre just done. -Josh Evans, Director of Operations Engineering @Netflix

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Reporting Database Server

    Hot

    Hot

    Database Server

    GLB / DNS

  • https://www.infoq.com/presentations/netflix-failure-multiple-regions

    https://www.infoq.com/presentations/netflix-failure-multiple-regions

  • SCALE CUBE

    X axis - horizontal Scaling (Scale by Cloning)

    Z ax

    is - D

    ata P

    artiti

    oning

    (Sca

    le by

    Sha

    rding

    )Y axis - Functional Decomposition

    (Scale by Splitting)

  • The CAP theorem is the idea that a distributed computing system is not able to provide partition tolerance, consistency and availability at

    the same time.

  • MICROSERVICESPATTERNS & PRACTICES

    AVAILABILITY/PARTITION TOLERANCE

    CONSISTENCY/PARTITION TOLERANCE CP: Choose Consistency over Availability when your business

    requirements dictate atomic reads and writes. Wait for a response from the partitioned node which could result in a timeout error. The

    system can also choose to return an error, depending on the scenario you desire.

    AP: Choose Availability over Consistency when your business requirements allow for some flexibility around when the data in the

    system synchronizes. Return the most recent version of the data you have, which could be stale. This system state will also accept writes that can be processed later when the partition is resolved. Availability is also

    a compelling option when the system needs to continue to function in spite of external errors (shopping carts, etc.)

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Reporting Database Server

    Hot

    Hot

    Database Server

    GLB / DNS

  • Evolu&onary Architecture

    Scale Cube

    CAP Theorem

    Microservices is a architecture that conFnues to change

    and adapt

    Scale Cube consists of an X, Y and Z axes each

    addressing a different approach to scale a service.

    The idea that a distributed compuFng system is not able

    to provide parFFon tolerance, consistency and availability

    at the same Fme.

    FIRST PRINCIPLESThings we need to

    understand about as we plan/scale systems

    DevOps is a MustMicroservices is the first architecture post devops culture

    shiP

  • TECHNICAL Tools, Event Sourcing, CQRS,

    Circuit Breaker, Retrys

    OPERATIONALObservability, Containers, Polyglot

    CULTURALDevOps Culture, Conways Law

    MICROSERVICESPATTERNS & PRACTICES

    123

  • TOOLS

    Everything is a tradeoff just be intentional about them

  • SPINE MODEL

    Needs: We are here to satisfy ________

    Values before PrinciplesWe optimize for ________

    Principles before Practices We leverage _____ to change the system

    Practices before tools We do _____ to create value

    We have always been Tool users and makers. Tools should answer the question: We use ____ to get our work done.

    http://spinemodel.info/explanation/introduction/

  • Proxy / Load Balancer

    Web Server

    Database Server

    Application Server

    Web Server Web Server

    Application Server

    Proxy / Load Balancer

    Web Server

    Application Server

    Web Server Web Server

    Application Server

    Reporting Database Server

    Hot

    Hot

    Database Server

    GLB / DNS

  • Hot

    Hot

    GLB / DNS

    User Facing AvailabilityConcerns

    Internal Consistency Concerns

    User Facing AvailabilityConcerns

    Internal Consistency Concerns

  • Hot

    Hot

    GLB / DNS

    High Reads

    High Writes

    High Reads

    High Writes

  • Hot

    Hot

    GLB / DNS

    High Reads

    High Writes

    High Reads

    High Writes

  • https://www.infoq.com/presentations/wix-microservices-devops

  • EVENT SOUR

    CING

    Yes, I think we should talk about this again.

  • Student Enroll In Workshop Security Module Student Module Workshop Module

    reserveSeat() isAuthorized()

    isEligible()

    isAvailable()

    updateSchedule()

    updateSchedule()

    ALL SY

    NCHRON

    OUS

    MUTIAB

    LE STAT

    E!

  • The fundamental idea of Event Sourcing is that of ensuring every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application

    state itself.- M Fowler

  • Student Enroll In Workshop Security Module Student Module Workshop ModuleQueue/Topic

    subscribe()subscribe()

    subscribe()

    reserveSeat() isAuthorized()

    reserveSeat()

    ASYNCH

    RONOUS

    IMMUTI

    ABLE S

    TATE!

    updateSchedule()

    updateSchedule()

    Par

  • Immutable Events

    Recreate the exact state

    Increase in complexity

    Performance / Load tes&ng

    Provides a model to think about scalability

    Because you have all of the state changes, you have all of

    the changes that affected state

    No longer doing CRUD. You have calculate the result.

    Leverage things like snapshots

    You an reply the events across the Enterprise

    EVENT SOURCINGThe fundamental idea of Event

    Sourcing is that of ensuring every change to the state of an

    application is captured in an event object, and that these

    event objects are themselves stored in the sequence they

    were applied for the same lifetime as the application state

    itself.

  • CQRS

    Decouple queries from Commands to scale each independently.

  • Presentation

    Business Logic

    DAO Data Storage

    Updates / Queries

  • Command and Query Responsibility Segregation (CQRS) is a pattern that se

Recommended

View more >