Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microservices metrowest web developers 2016-09-14

130 views

Published on

Slides from MetroWest Web Developers meetup on Microservices
http://www.meetup.com/MetroWest-web-developers/events/233792117/

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Microservices metrowest web developers 2016-09-14

  1. 1. Microservices What are they, why use them, and how?
  2. 2. Who Am I? Rob Raisch Senior Staff Software Engineer @ Yieldbot Team Lead - Config Services More than 30 years online experience - "Internet Greybeard"
  3. 3. Overview What are Microservices? Definition, History Why are they desirable? Characteristics, Drawbacks How should I organize/define them? Business Domains How about a quick example?
  4. 4. What Are Microservices?
  5. 5. What are Microservices? - Definition An Architectural Design Pattern of: Small, Autonomous Modular Services That Are Independently and Automatically Deployable Using Lightweight Communication Mechanisms
  6. 6. What are Microservices? - Definition An Architectural Design Pattern of: Small, Autonomous Modular Services That Are Independently and Automatically Deployable Using Lightweight Communication Mechanisms Do Only One Thing And Do It Well
  7. 7. What are Microservices? - Example Monolithic Service Graphic blatently stolen from microservices.io
  8. 8. What are Microservices? - Example Microservices Graphic blatently stolen from microservices.io
  9. 9. Microservices - History A World of Small Interconnected Things Unix Pipefitting - $> cat file.txt | awk '{print $2}' | sort | uniq > result.txt Remote Procedure Call (RPC) - ASN.1, CORBA/IDL, etc. Message Passing and Event Busses - Document Object Model, PubSub, ZeroMQ, etc. SOA - XML, WSDL, SOAP, etc. Microservices
  10. 10. Microservices - History A World of Small Interconnected Things Unix Pipefitting - $> cat file.txt | awk '{print $2}' | sort | uniq > result.txt Remote Procedure Call (RPC) - ASN.1, CORBA/IDL, etc. Message Passing and Event Busses - Document Object Model, PubSub, ZeroMQ, etc. SOA - XML, WSDL, SOAP, etc. Everything is deeply intertwingled. - Ted Nelson
  11. 11. Why Are Microservices Desirable? Why Are Microservices Desirable? Why Are Microservices Desirable?
  12. 12. Why Are Microservices Desirable? Increase Cohesion Reduce Coupling Improved Resilience Optimized for Replaceability Better Alignment With Business Processes Better Composability Better Scaling Technological Heterogeneity
  13. 13. Why Are Microservices Desirable? Increase Cohesion Group related functionality together "Gather together those things that change for the same reason and separate those things that change for different reasons." - Robert C. Martin's Single Responsibility Principle
  14. 14. Why Are Microservices Desirable? Reduce Coupling - Separation of responsibilities Coupling - the manner and degree of interdependence between software components. Connascence - where a change to one software component requires changes to other components.
  15. 15. Why Are Microservices Desirable? Improved Resilience Monolithic systems tend to fail completely. Design so a failure of one software component will not cause the entire system to fail, thus improving overall "fault tolerance" Service boundaries become natural "bulkheads" and so reduce the "cascade" of failure.
  16. 16. Why Are Microservices Desirable? Optimized for Replaceability As long as service contracts remain the same, all components can be easily replaced. Lessen technical debt Reduce costs to replace underlying technologies
  17. 17. Why Are Microservices Desirable? Better Alignment With Business Processes Organized around business domains Reduce development team size Help focus participation from elsewhere in the organization
  18. 18. Why Are Microservices Desirable? Better Composability Monolithic systems cannot be easily reorganized as needs change Lots of little independent workers that can be organized in different ways Better software reuse - "DRY it up!"
  19. 19. Why Are Microservices Desirable? Better Scaling In Monolithic systems, everything must be scaled together Using routing, requests can be directed to one of several instances of the same service (see nginx) The architecture can be scaled as needed
  20. 20. Why Are Microservices Desirable? Technological Heterogeneity Monolithic systems are typically written in a single language. No requirement that all services be expressed in the same language Use "the right tool for the right job"
  21. 21. Why Are Microservices Desirable? Ease of Deployment New functionality can be easily deployed as needed. No "BIG" deploys reduce downtime. "Deliver often" - Continuous Integration/Deployment
  22. 22. What Are The Drawbacks Of Microservices? Distributed systems can be much more complex than monolithic ones. The "Big Picture" can be difficult to envision without good documentation. Operational Overhead Interactions can be hard to track without copious, centralized logging. Network latency must be monitored and managed well.
  23. 23. Why Are Microservices Desirable? Why Are Microservices Desirable? How Should Microservices Be Designed?
  24. 24. How Should Microservices Be Designed? Identify Domains Aligned to Business Units Authorization Payments - Deposits, Ledgers, Reconciliation Billing Reporting Support Not Components! Responsibilities!
  25. 25. How Should Microservices Be Designed? Identify Stakeholders And Include Them In Design Process Carve Out Well-Defined Functionality Keep Martin's Single Responsibility Principle in mind at all times.
  26. 26. How Should Microservices Be Designed? Identify Stakeholders And Include Them In Design Process Carve Out Well-Defined Functionality Keep Martin's Single Responsibility Principle in mind at all times. "Gather together those things that change for the same reason and separate those things that change for different reasons."
  27. 27. How Should Microservices Be Designed? The BIG QUESTION: How to determine the best size for a microservice?
  28. 28. How Should Microservices Be Designed? The BIG QUESTION: How to determine the best size for a microservice? The BIG ANSWER: As Small As They Need To Be To Solve A Need
  29. 29. How Should Microservices Be Designed? The BIG QUESTION: How to determine the best size for a microservice? The BIG ANSWER: As Small As They Need To Be To Solve A Need BUT NO SMALLER!
  30. 30. Why Are Microservices Desirable? Why Are Microservices Desirable? An Example Using Node/Seneca
  31. 31. Microservice in Seneca - Server const _ = require('lodash'); const SenecaFactory = require('seneca'); const seneca = SenecaFactory(); seneca.add('cmd:sum', (msg, respond) => { let errs = []; const left = Number(_.get(msg,'left',0)); const right = Number(_.get(msg,'right',0)); if(_.isNaN(left)) errs.push(new Error('left operand must evaluate to a number')); if(_.isNaN(right)) errs.push(new Error('right operand must evaluate to a number')); if(errs.length) { respond(errs); } else { const result = Math.floor(left) + Math.floor(right); respond(null, { answer: result }); } });
  32. 32. Microservice in Seneca - Server Side Call // To call microservice from the same process… seneca.act({cmd: 'sum', left: 1, right: 2}, (err, result) => { if (err) { console.error(err); return; } console.log(`The result is ${result}`); });
  33. 33. Summary Architectural Pattern of Small, Independent Loosely-Coupled Services Many Useful Benefits For Medium/Large Systems Though By No Means A Panacea! Do Only One Thing But Do It Very Well Organize Around Business Domains Carve Out Well-Defined Functionality As Small As Needs Dictate But No Smaller
  34. 34. Summary Architectural Pattern of Small, Independent Loosely-Coupled Services Many Useful Benefits For Medium/Large Systems Though By No Means A Panacea! Do Only One Thing But Do It Very Well Organize Around Business Domains Carve Out Well-Defined Functionality As Small As Needs Dictate But No Smaller
  35. 35. We Are Hiring! IT Lead Engineering Manager, Infrastructure Front End Software Engineer Server-side Javascript Engineer DevOps Engineer Software Test Engineer - Ad Serving Platform Platform Software Engineer - Ad Serving
  36. 36. Thanks for your time! rraisch@yieldbot.com

×