Upgrade to Pro — share decks privately, control downloads, hide ads and more …

12-factor Microservices

Ian Kent
November 29, 2016

12-factor Microservices

12-factor microservices, distributed systems and event driven architecture for ONS Software Engineer Community of Practice

Code is on GitHub: https://github.com/ONSdigital/software-engineer-cop-12-factor-microservices

Ian Kent

November 29, 2016
Tweet

More Decks by Ian Kent

Other Decks in Technology

Transcript

  1. 12-factor microservices • What is 12-factor? • What are microservices?

    • What are distributed systems? • What is event driven architecture?
  2. The twelve factors • Portability between environments • Suitable for

    modern platforms • Supports continuous deployment • Can scale without significant changes Why use 12-factor?
  3. The twelve factors • Codebase • Dependencies • Config •

    Backing services • Build, release, run • Processes • Port binding • Concurrency • Disposability • Dev/prod parity • Logs • Admin processes More info https://12factor.net
  4. A baby names API What does it do? • One

    endpoint: GET /top10 • Simple JSON response:
  5. Microservices Microservice myths • Can be rewritten in two weeks

    • Less than 50 lines of code • More difficult to design • More difficult to build and deploy
  6. Microservices What is a microservice? • Single responsibility • Bounded

    context • Well defined interfaces • Composable
  7. Microservices Why use microservices? • Clear, concise code • Better

    fault tolerance • Lower risk deployments • Flexible technology choices
  8. Microservices What are the challenges? • Interfaces • Distributed systems

    • Complex architecture • Build and deployment
  9. Distributed systems What are they? • Spread across physical servers,

    datacentre’s and continents • Coordinate by passing messages • Fail often, in unexpected ways • Suffers from CAP theorem
  10. Distributed systems The fallacies • The network is reliable •

    Bandwidth is infinite • Topology doesn't change • Transport cost is zero • Latency is zero • The network is secure • There is one administrator • The network is homogeneous
  11. A baby names API What does it do? • One

    endpoint: POST /baby • Simple JSON input:
  12. A baby names API So why not? • Complexity •

    Security • Scaling • Risk
  13. Event driven architecture What is it? • Asynchronous • Fault

    tolerant • Scalable • Resilient under load
  14. A baby names API What does it do? • One

    endpoint: GET /stream • Simple JSON output stream:
  15. A baby names API So why not? • ~2k new

    babies per day • Atomic database updates • Top 10 changes infrequently • How does streaming work?
  16. A baby names API Baby name events • New baby

    registration • Send to streaming API users • Update database • Has top 10 changed? • Notify output API
  17. 12-factor microservices • What is 12-factor? • What are microservices?

    • What are distributed systems? • What is event driven architecture?