Microservices: Flexible Software Architecture

Book description

The Most Complete, Practical, and Actionable Guide to Microservices

Going beyond mere theory and marketing hype, Eberhard Wolff presents all the knowledge you need to capture the full benefits of this emerging paradigm. He illuminates microservice concepts, architectures, and scenarios from a technology-neutral standpoint, and demonstrates how to implement them with today’s leading technologies such as Docker, Java, Spring Boot, the Netflix stack, and Spring Cloud.

The author fully explains the benefits and tradeoffs associated with microservices, and guides you through the entire project lifecycle: development, testing, deployment, operations, and more. You’ll find best practices for architecting microservice-based systems, individual microservices, and nanoservices, each illuminated with pragmatic examples. The author supplements opinions based on his experience with concise essays from other experts, enriching your understanding and illuminating areas where experts disagree. Readers are challenged to

experiment on their own the concepts explained in the book to gain hands-on experience.

  • Discover what microservices are, and how they differ from other forms of

  • modularization

  • Modernize legacy applications and efficiently build new systems

  • Drive more value from continuous delivery with microservices

  • Learn how microservices differ from SOA

  • Optimize the microservices project lifecycle

  • Plan, visualize, manage, and evolve architecture

  • Integrate and communicate among microservices

  • Apply advanced architectural techniques, including CQRS and Event Sourcing

  • Maximize resilience and stability

  • Operate and monitor microservices in production

  • Build a full implementation with Docker, Java, Spring Boot, the Netflix stack, and Spring Cloud

  • Explore nanoservices with Amazon Lambda, OSGi, Java EE, Vert.x, Erlang, and Seneca

  • Understand microservices’ impact on teams, technical leaders, product owners, and stakeholders

  • Managers will discover better ways to support microservices, and learn how adopting the method affects the entire organization. Developers will master the technical skills and concepts they need to be effective. Architects will gain a deep understanding of key issues in creating or migrating toward microservices, and exactly what it will take to transform their plans into reality. 

    Table of contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Dedication
    5. Contents at a Glance
    6. Contents
    7. Preface
      1. Overview of the Book
      2. For Whom Is the Book Meant?
        1. Managers
        2. Developers
        3. Architects
      3. Structure and Coverage
        1. Part I: Motivation and Basics
        2. Part II: Microservices—What, Why, and Why Not?
        3. Part III: Implementing Microservices
        4. Part IV: Technologies
      4. Essays
      5. Paths through the Book
      6. Supplementary Materials
    8. Acknowledgments
    9. About the Author
    10. Part I: Motivation and Basics
      1. Chapter 1. Preliminaries
        1. 1.1 Overview of Microservice
          1. Microservice: Preliminary Definition
          2. Deployment Monoliths
        2. 1.2 Why Microservices?
          1. Strong Modularization
          2. Easy Replaceability
          3. Sustainable Development
          4. Further Development of Legacy Applications
          5. Time-to-Market
          6. Independent Scaling
          7. Free Choice of Technologies
          8. Continuous Delivery
        3. 1.3 Challenges
        4. 1.4 Conclusion
      2. Chapter 2. Microservice Scenarios
        1. 2.1 Modernizing an E-Commerce Legacy Application
          1. Scenario
          2. Reasons to Use Microservices
          3. Slow Continuous Delivery Pipeline
          4. Parallel Work Is Complicated
          5. Bottleneck During Testing
          6. Approach
          7. Challenges
          8. Entire Migration Lengthy
          9. Testing Remains a Challenge
          10. Current Status of Migration
          11. Creating Teams
          12. Advantages
          13. Conclusion
          14. Rapid and Independent Development of New Features
          15. Influence on the Organization
          16. Amazon Has Been Doing It for a Long Time
        2. 2.2 Developing a New Signaling System
          1. Scenario
          2. Reasons to Use Microservices
          3. Distributed System
          4. Technology Stack per Team
          5. Integration of Other Systems
          6. Challenges
          7. High Technological Complexity
          8. Advantages
          9. Verdict
        3. 2.3 Conclusion
          1. Essential Points
    11. Part II: Microservices: What, Why, and Why Not?
      1. Chapter 3. What Are Microservices?
        1. 3.1 Size of a Microservice
          1. Modularization
          2. Distributed Communication
          3. Sustainable Architecture
          4. Refactoring
          5. Team Size
          6. Infrastructure
          7. Replaceability
          8. Transactions and Consistency
          9. Consistency
          10. Compensation Transactions across Microservices
          11. Summary
        2. 3.2 Conway’s Law
          1. Reasons for the Law
          2. The Law as Limitation
          3. The Law as Enabler
          4. The Law and Microservices
        3. 3.3 Domain-Driven Design and Bounded Context
          1. Ubiquitous Language
          2. Building Blocks
          3. Bounded Context
          4. Collaboration between Bounded Contexts
          5. Bounded Context and Microservices
          6. Large-Scale Structure
        4. 3.4 Why You Should Avoid a Canonical Data Model (Stefan Tilkov)
        5. 3.5 Microservices with a UI?
          1. Technical Alternatives
          2. Self-Contained System
        6. 3.6 Conclusion
          1. Essential Points
      2. Chapter 4. Reasons for Using Microservices
        1. 4.1 Technical Benefits
          1. Replacing Microservices
          2. Sustainable Software Development
          3. Handling Legacy
          4. Continuous Delivery
          5. Scaling
          6. Robustness
          7. Free Technology Choice
          8. Independence
        2. 4.2 Organizational Benefits
          1. Smaller Projects
        3. 4.3 Benefits from a Business Perspective
          1. Parallel Work on Stories
        4. 4.4 Conclusion
          1. Essential Points
      3. Chapter 5. Challenges
        1. 5.1 Technical Challenges
          1. Code Dependencies
          2. Unreliable Communication
          3. Technology Pluralism
        2. 5.2 Architecture
          1. Architecture = Organization
          2. Architecture and Requirements
          3. Refactoring
          4. Agile Architecture
          5. Summary
        3. 5.3 Infrastructure and Operations
          1. Continuous Delivery Pipelines
          2. Monitoring
          3. Version Control
        4. 5.4 Conclusion
          1. Essential Points
      4. Chapter 6. Microservices and SOA
        1. 6.1 What Is SOA?
          1. Introducing SOA
          2. Services in an SOA
          3. Interfaces and Versioning
          4. External Interfaces
          5. Interfaces Enforce a Coordination of Deployments
          6. Coordination and Orchestration
          7. Technologies
        2. 6.2 Differences between SOA and Microservices
          1. Communication
          2. Orchestration
          3. Flexibility
          4. Microservices: Project Level
          5. Synergies
        3. 6.3 Conclusion
          1. Essential Points
    12. Part III: Implementing Microservices
      1. Chapter 7. Architecture of Microservice-Based Systems
        1. 7.1 Domain Architecture
          1. Strategic Design and Domain-Driven Design
          2. Example Otto Shop
          3. Managing Dependencies
          4. Unintended Domain-Based Dependencies
          5. Cyclic Dependencies
        2. 7.2 Architecture Management
          1. Tools for Architecture Management
          2. Cycle-Free Software
          3. Microservices and Architecture Management
          4. Tools
          5. Is Architecture Management Important?
          6. Context Map
        3. 7.3 Techniques to Adjust the Architecture
          1. Where Does Bad Architecture Come From?
          2. Changes in Microservices
          3. Changes to the Overall Architecture
          4. Shared Libraries
          5. Transfer Code
          6. Reuse or Redundancy?
          7. Shared Service
          8. Spawn a New Microservice
          9. Rewriting
          10. A Growing Number of Microservices
          11. Microservice-Based Systems Are Hard to Modify
        4. 7.4 Growing Microservice-Based Systems
          1. Planning Architecture?
          2. Start Big
          3. Start Small?
          4. Limits of Technology
          5. Replaceability as a Quality Criterion
          6. The Gravity of Monoliths
          7. Keep Splitting
          8. Global Architecture?
        5. 7.5 Don’t Miss the Exit Point or How to Avoid the Erosion of a Microservice (Lars Gentsch)
          1. Incorporation of New Functionality
          2. What Is Happening to the Microservice Here?
          3. Criteria Arguing for a New Microservice Instead of Extending an Existing One
          4. How to Recognize Whether the Creation of a New Microservice Should Have Occurred Already
          5. Conclusion
        6. 7.6 Microservices and Legacy Applications
          1. Breaking Up Code?
          2. Supplementing Legacy Applications
          3. Enterprise Integration Patterns
          4. Limiting Integration
          5. Advantages
          6. Integration via UI and Data Replication
          7. Content Management Systems
          8. Conclusion
          9. No Big Bang
          10. Legacy = Infrastructure
          11. Other Qualities
        7. 7.7 Hidden Dependencies (Oliver Wehrens)
          1. The Database
        8. 7.8 Event-Driven Architecture
        9. 7.9 Technical Architecture
          1. Technical Decisions for the Entire System
          2. Sidecar
        10. 7.10 Configuration and Coordination
          1. Consistency as Problem
          2. Immutable Server
          3. Alternative: Installation Tools
        11. 7.11 Service Discovery
          1. Service Discovery = Configuration?
          2. Technologies
        12. 7.12 Load Balancing
          1. REST/HTTP
          2. Central Load Balancer
          3. A Load Balancer per Microservice
          4. Technologies
          5. Service Discovery
          6. Client-Based Load Balancing
          7. Load Balancing and Architecture
        13. 7.13 Scalability
          1. Scaling, Microservices, and Load Balancing
          2. Dynamic Scaling
          3. Microservices: Advantages for Scaling
          4. Sharding
          5. Scalability, Throughput, and Response Times
        14. 7.14 Security
          1. Security and Microservices
          2. OAuth2
          3. Possible Authorization Grants
          4. JSON Web Token (JWT)
          5. OAuth2, JWT, and Microservices
          6. Technologies
          7. Additional Security Measures
          8. Hashicorp Vault
          9. Additional Security Goals
        15. 7.15 Documentation and Metadata
          1. Outdated Documentation
          2. Access to Documentation
        16. 7.16 Conclusion
          1. Essential Points
      2. Chapter 8. Integration and Communication
        1. 8.1 Web and UI
          1. Multiple Single-Page-Apps
          2. SPA per Microservice
          3. Asset Server for Uniformity
          4. A Single-Page App for All Microservices
          5. HTML Applications
          6. ROCA
          7. Easy Routing
          8. Arrange HTML with JavaScript
          9. Front-End Server
          10. Mobile Clients and Rich Clients
          11. Organizational Level
          12. Back-End for Each Front-End
        2. 8.2 REST
          1. Cache and Load Balancer
          2. HATEOAS
          3. HAL
          4. XML
          5. HTML
          6. JSON
          7. Protocol Buffer
          8. RESTful HTTP Is Synchronous
        3. 8.3 SOAP and RPC
          1. Flexible Transport
          2. Thrift
        4. 8.4 Messaging
          1. Messages and Transactions
          2. Messaging Technology
        5. 8.5 Data Replication
          1. Replication
          2. Problems: Redundancy and Consistency
          3. Implementation
          4. Batch
          5. Event
        6. 8.6 Interfaces: Internal and External
          1. External Interfaces
          2. Separating Interfaces
          3. Implementing External Interfaces
          4. Semantic Versioning
          5. Postel’s Law or the Robustness Principle
        7. 8.7 Conclusion
          1. Client
          2. Logic Layer
          3. Data Replication
          4. Interfaces and Versions
          5. Essential Points
      3. Chapter 9. Architecture of Individual Microservices
        1. 9.1 Domain Architecture
          1. Cohesion
          2. Encapsulation
          3. Domain-Driven Design
          4. Transactions
        2. 9.2 CQRS
          1. CQRS
          2. Microservices and CQRS
          3. Advantages
          4. Challenges
        3. 9.3 Event Sourcing
        4. 9.4 Hexagonal Architecture
          1. Hexagons or Layers?
          2. Hexagonal Architectures and Microservices
          3. An Example
        5. 9.5 Resilience and Stability
          1. Timeout
          2. Circuit Breaker
          3. Bulkhead
          4. Steady State
          5. Fail Fast
          6. Handshaking
          7. Test Harness
          8. Uncoupling via Middleware
          9. Stability and Microservices
          10. Resilience and Reactive
          11. Hystrix
        6. 9.6 Technical Architecture
          1. Process Engines
          2. Statelessness
          3. Reactive
          4. Microservices without Reactive?
        7. 9.7 Conclusion
          1. Essential Points
      4. Chapter 10. Testing Microservices and Microservice-Based Systems
        1. 10.1 Why Tests?
          1. Tests Minimize Expenditure
          2. Tests = Documentation
          3. Test-Driven Development
        2. 10.2 How to Test?
          1. Unit Tests
          2. Integration Tests
          3. UI Tests
          4. Manual Tests
          5. Load Tests
          6. Test Pyramid
          7. Continuous Delivery Pipeline
        3. 10.3 Mitigate Risks at Deployment
        4. 10.4 Testing the Overall System
          1. Shared Integration Tests
          2. Avoiding Integration Tests of the Overall System
        5. 10.5 Testing Legacy Applications and Microservices
          1. Relocating Tests of the Legacy Application
          2. Integration Test: Legacy Application and Microservices
        6. 10.6 Testing Individual Microservices
          1. Reference Environment
          2. Stubs
        7. 10.7 Consumer-Driven Contract Tests
          1. Components of the Contract
          2. Contracts
          3. Implementation
          4. Tools
        8. 10.8 Testing Technical Standards
        9. 10.9 Conclusion
          1. Essential Points
      5. Chapter 11. Operations and Continuous Delivery of Microservices
        1. 11.1 Challenges Associated with the Operation of Microservices
          1. Numerous Artifacts
          2. Delegate into Teams
          3. Unify Tools
          4. Specify Behavior
          5. Micro and Macro Architecture
          6. Templates
        2. 11.2 Logging
          1. Logging for Microservices
          2. Technologies for Logging via the Network
          3. ELK for Centralized Logging
          4. Scaling ELK
          5. Graylog
          6. Splunk
          7. Stakeholders for Logs
          8. Correlation IDs
          9. Zipkin: Distributed Tracing
        3. 11.3 Monitoring
          1. Basic Information
          2. Additional Metrics
          3. Stakeholders
          4. Correlate with Events
          5. Monitoring = Tests?
          6. Dynamic Environment
          7. Concrete Technologies
          8. Enabling Monitoring in Microservices
          9. Metrics
          10. StatsD
          11. collectd
          12. Technology Stack for Monitoring
          13. Effects on the Individual Microservice
        4. 11.4 Deployment
          1. Deployment Automation
          2. Installation and Configuration
          3. Risks Associated with Microservice Deployments
          4. Deployment Strategies
        5. 11.5 Combined or Separate Deployment? (Jörg Müller)
        6. 11.6 Control
        7. 11.7 Infrastructure
          1. Virtualization or Cloud
          2. Docker
          3. Docker Container versus Virtualization
          4. Communication between Docker Containers
          5. Docker Registry
          6. Docker and Microservices
          7. Docker and Servers
          8. PaaS
        8. 11.8 Conclusion
          1. Essential Points
      6. Chapter 12. Organizational Effects of a Microservices-Based Architecture
        1. 12.1 Organizational Benefits of Microservices
          1. Technical Independence
          2. Separate Deployment
          3. Separate Requirement Streams
          4. Three Levels of Independence
        2. 12.2 An Alternative Approach to Conway’s Law
          1. The Challenges Associated with Conway’s Law
          2. Collective Code Ownership
          3. Advantages of Collective Code Ownership
          4. Disadvantages of Collective Code Ownership
          5. Pull Requests for Coordination
        3. 12.3 Micro and Macro Architecture
          1. Decision = Responsibility
          2. Who Creates the Macro Architecture?
          3. Extent of the Macro Architecture
          4. Technology: Macro/Micro Architecture
          5. Operations
          6. Domain Architecture
          7. Tests
        4. 12.4 Technical Leadership
          1. Developer Anarchy
        5. 12.5 DevOps
          1. DevOps and Microservices
          2. Do Microservices Necessitate DevOps?
        6. 12.6 When Microservices Meet Classical IT Organizations (Alexander Heusingfeld)
          1. Pets versus Cattle
          2. Us versus Them
          3. Development versus Test versus Operations: Change of Perspective
          4. For Operations There Is Never an “Entirely Green Field”
          5. Conclusion
        7. 12.7 Interface to the Customer
          1. Architecture Leads to Departments
        8. 12.8 Reusable Code
          1. Client Libraries
          2. Reuse Anyhow?
          3. Reuse as Open Source
        9. 12.9 Microservices without Changing the Organization?
          1. Microservices without Changing the Organization
          2. Evaluation
          3. Departments
          4. Operations
          5. Architecture
        10. 12.10 Conclusion
          1. Essential Points
    13. Part IV: Technologies
      1. Chapter 13. Example of a Microservices-Based Architecture
        1. 13.1 Domain Architecture
          1. Separate Data Storages
          2. Lots of Communication
          3. Bounded Context
          4. Don’t Modularize Microservices by Data!
        2. 13.2 Basic Technologies
          1. HSQL Database
          2. Spring Data REST
          3. Spring Boot
          4. Spring Cloud
          5. Spring Cloud Netflix
        3. 13.3 Build
        4. 13.4 Deployment Using Docker
        5. 13.5 Vagrant
          1. Networking in the Example Application
        6. 13.6 Docker Machine
        7. 13.7 Docker Compose
        8. 13.8 Service Discovery
          1. Eureka Client
          2. Configuration
          3. Eureka Server
        9. 13.9 Communication
          1. Zuul: Routing
        10. 13.10 Resilience
          1. Circuit Breaker
          2. Hystrix with Annotations
          3. Monitoring with the Hystrix Dashboard
          4. Turbine
        11. 13.11 Load Balancing
          1. Ribbon with Spring Cloud
        12. 13.12 Integrating Other Technologies
        13. 13.13 Tests
          1. Stubs
          2. Consumer-Driven Contract Test
        14. 13.14 Experiences with JVM-Based Microservices in the Amazon Cloud (Sascha Möllering)
          1. Conclusion
        15. 13.15 Conclusion
          1. Essential Points
      2. Chapter 14. Technologies for Nanoservices
        1. 14.1 Why Nanoservices?
          1. Minimum Size of Microservices is Limited
          2. Compromises
          3. Desktop Applications
        2. 14.2 Nanoservices: Definition
        3. 14.3 Amazon Lambda
          1. Calling Lambda Functions
          2. Evaluation for Nanoservices
          3. Conclusion
        4. 14.4 OSGi
          1. The OSGi Module System
          2. Handling Bundles in Practice
          3. Evaluation for Nanoservices
          4. Conclusion
        5. 14.5 Java EE
          1. Nanoservices with Java EE
          2. Microservices with Java EE?
          3. An Example
        6. 14.6 Vert.x
          1. Conclusion
        7. 14.7 Erlang
          1. Evaluation for Nanoservices
        8. 14.8 Seneca
          1. Evaluation for Nanoservices
        9. 14.9 Conclusion
          1. Essential Points
      3. Chapter 15. Getting Started with Microservices
        1. 15.1 Why Microservices?
        2. 15.2 Roads towards Microservices
        3. 15.3 Microservice: Hype or Reality?
        4. 15.4 Conclusion
    14. Index
    15. Code Snippets

    Product information

    • Title: Microservices: Flexible Software Architecture
    • Author(s): Eberhard Wolff
    • Release date: October 2016
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780134650449