microservices: from theory to · pdf filesunil joshi valerie lampkin ... viii microservices...

Post on 06-Feb-2018

223 Views

Category:

Documents

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

  • Redbooks

    Front cover

    Microservices from Theory to PracticeCreating Applications in IBM Bluemix Using the Microservices Approach

    Shahir Daya

    Nguyen Van Duy

    Kameswara Eati

    Carlos M Ferreira

    Dejan Glozic

    Vasfi Gucer

    Manav Gupta

    Sunil Joshi

    Valerie Lampkin

    Marcelo Martins

    Shishir Narain

    Ramratan Vennam

  • International Technical Support Organization

    Microservices from Theory to Practice: Creating Applications in IBM Bluemix Using the Microservices Approach

    August 2015

    SG24-8275-00

  • Copyright International Business Machines Corporation 2015. All rights reserved.Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP ScheduleContract with IBM Corp.

    First Edition (August 2015)

    This edition applies to IBM Bluemix Version 1.0.

    Note: Before using this information and the product it supports, read the information in Notices on page vii.

  • Contents

    Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viiTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii

    IBM Redbooks promotions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiAuthors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiNow you can become a published author, too . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvComments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvStay connected to IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

    Part 1. Introducing the microservices architectural style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Chapter 1. Motivations for microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1 What are microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.1.1 Small and focused . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.2 Loosely coupled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.3 Language-neutral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.4 Bounded context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.5 Comparing microservices and monolithic architectures . . . . . . . . . . . . . . . . . . . . . 6

    1.2 Benefits from microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2.1 Enterprise solutions context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.2.2 Challenges with monolithic architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.2.3 Developer perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.2.4 Tester perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.2.5 Business owner perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.2.6 Service management perspective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.3 What to avoid with microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.3.1 Dont start with microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.2 Dont even think about microservices without DevOps. . . . . . . . . . . . . . . . . . . . . 111.3.3 Dont manage your own infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.4 Dont create too many microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.5 Dont forget to keep an eye on the potential latency issue . . . . . . . . . . . . . . . . . . 12

    1.4 How is this different than service-oriented architecture?. . . . . . . . . . . . . . . . . . . . . . . . 121.5 Case studies and most common architectural patterns . . . . . . . . . . . . . . . . . . . . . . . . 14

    1.5.1 An e-commerce discount site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.5.2 Financial services company . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.5.3 Large brick-and-mortar retailer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    1.6 Example scenarios using microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.6.1 Cloud Trader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.6.2 Online Store . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.6.3 Acme Air . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    Chapter 2. Elements of a microservices architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 192.1 Characteristics of microservices architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    2.1.1 Business-oriented . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.1.2 Design for failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.1.3 Decentralized data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1.4 Discoverability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    Copyright IBM Corp. 2015. All rights reserved. iii

  • 2.1.5 Inter-service communication design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.1.6 Dealing with complexity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.1.7 Evolutionary design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    2.2 Designing microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.2.1 Use design thinking to scope and identify microservices . . . . . . . . . . . . . . . . . . . 292.2.2 Choosing the implementation stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.2.3 Sizing the microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    2.3 REST API and messaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.3.1 REST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.3.2 Messaging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.3.3 REST and messaging together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.4 The future of microservices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    Chapter 3. Microservices and DevOps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.1 Why you should use DevOps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    3.1.1 Defining DevOps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.1.2 DevOps is a prerequisite to successfully adopting microservices. . . . . . . . . . . . . 403.1.3 Organizing teams to support microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.1.4 Organize a DevOps team to support other microservices teams . . . . . . . . . . . . . 41

    3.2 DevOps capabilities for microservices architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.2.1 Continuous business planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.2.2 Continuous integration and collaborative development . . . . . . . . . . . . . . . . . . . . 443.2.3 Continuous testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.2.4 Continuous release and deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.2.5 Continuous monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.2.6 Continuous customer feedback and optimization . . . . . . . . . . . . . . . . . . . . . . . . . 47

    3.3 Microservices governance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.3.1 Centralized versus decentralized governance . . . . . . . . . . . . . . . . . . . . . . . . . . . 483.3.2 Enterprise transformation for microservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    3.4 DevOps capabilities: Testing strategies for microservices . . . . . . . . . . . . . . . . . . . . . .

top related