Embracing Microservices Design

Book description

Develop microservice-based enterprise applications with expert guidance to avoid failures and technological debt with the help of real-world examples

Key Features

  • Implement the right microservices adoption strategy to transition from monoliths to microservices
  • Explore real-world use cases that explain anti-patterns and alternative practices in microservices development
  • Discover proven recommendations for avoiding architectural mistakes when designing microservices

Book Description

Microservices have been widely adopted for designing distributed enterprise apps that are flexible, robust, and fine-grained into services that are independent of each other. There has been a paradigm shift where organizations are now either building new apps on microservices or transforming existing monolithic apps into microservices-based architecture.

This book explores the importance of anti-patterns and the need to address flaws in them with alternative practices and patterns. You'll identify common mistakes caused by a lack of understanding when implementing microservices and cover topics such as organizational readiness to adopt microservices, domain-driven design, and resiliency and scalability of microservices. The book further demonstrates the anti-patterns involved in re-platforming brownfield apps and designing distributed data architecture. You'll also focus on how to avoid communication and deployment pitfalls and understand cross-cutting concerns such as logging, monitoring, and security. Finally, you'll explore testing pitfalls and establish a framework to address isolation, autonomy, and standardization.

By the end of this book, you'll have understood critical mistakes to avoid while building microservices and the right practices to adopt early in the product life cycle to ensure the success of a microservices initiative.

What you will learn

  • Discover the responsibilities of different individuals involved in a microservices initiative
  • Avoid the common mistakes in architecting microservices for scalability and resiliency
  • Understand the importance of domain-driven design when developing microservices
  • Identify the common pitfalls involved in migrating monolithic applications to microservices
  • Explore communication strategies, along with their potential drawbacks and alternatives
  • Discover the importance of adopting governance, security, and monitoring
  • Understand the role of CI/CD and testing

Who this book is for

This practical microservices book is for software architects, solution architects, and developers involved in designing microservices architecture and its development, who want to gain insights into avoiding pitfalls and drawbacks in distributed applications, and save time and money that might otherwise get wasted if microservices designs fail. Working knowledge of microservices is assumed to get the most out of this book.

Publisher resources

Download Example Code

Table of contents

  1. Embracing Microservices Design
  2. Foreword
  3. Contributors
  4. About the authors
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. Download the color images
    4. Conventions used
    5. Get in touch
    6. Share Your Thoughts
  7. Section 1: Overview of Microservices, Design, and Architecture Pitfalls
  8. Chapter 1: Setting Up Your Mindset for a Microservices Endeavor
    1. Philosophy of microservices
    2. Microservice design principles
      1. Single responsibility principle and domain-driven design
      2. Encapsulation and interface segregation
      3. Culture of autonomy, ownership, and shared governance
      4. Independently deployable
      5. Culture of automation
      6. Designing for failures
      7. Observability
    3. Building teams to deliver business value faster
    4. Benefits of microservices
      1. Agility
      2. Maintainability
      3. Scalability
      4. Time to market
      5. Technology diversity
      6. Increased reliability
    5. Challenges of microservices
      1. Organizational culture
      2. Adoption of DevOps practices
      3. Architectural and operational complexity
      4. Service orchestration and choreography
      5. Observability
      6. End-to-end testing
      7. Double mortgage period
      8. Platform investment
    6. Microservice architecture components
      1. Messages
      2. Persistence and state management
      3. Orchestration
      4. Service discovery
      5. API gateway
    7. Reviewing leadership responsibilities
      1. What business/technology leaders must know
      2. What architects must know
      3. The role of the product manager, product owner, and scrum master
    8. Defining core priorities for a business
    9. Using the twelve-factor app methodology
      1. Code base
      2. Dependencies
      3. Config
      4. Backing service
      5. Build, release, and run
      6. Processes
      7. Port binding
      8. Concurrency
      9. Disposability
      10. Dev/prod parity
      11. Logs
      12. Admin processes
    10. Additional factors for modern cloud-native apps
      1. API first
      2. Telemetry
      3. Security
    11. Summary
    12. Questions
    13. Further reading
  9. Chapter 2: Failing to Understand the Role of DDD
    1. What are microservices and how do they align with DDD?
      1. Autonomous
      2. Independently deployable
      3. Data ownership
      4. Communication
      5. Technology-agnostic
      6. Gateway pattern service discovery
    2. Benefits and challenges of microservices as compared to DDD
    3. Lack of team alignment
    4. Lack of governance
    5. The whole is greater than the sum of its parts
      1. Autonomy
      2. What comes first – the data or the events?
    6. Microservices are based on science
    7. Complex or not complex – that is the question
      1. Obvious contexts – "the domain of best practice"
      2. Snowden's complicated contexts – "the domain of experts"
      3. Snowden's complex contexts – "the domain of emergence"
      4. A thin line between complicated and complex
      5. Snowden's chaotic context – "the domain of novel solutions"
      6. Snowden's disorder contexts – "the space in the middle"
      7. Our path is clear
      8. Event storming
    8. DDD
    9. A lack of awareness of stakeholder needs
      1. A knowledge-crunching domain model
      2. UL
      3. Binding the model to the implementation of our services
      4. Not a silver bullet
      5. Boundaries are important
    10. Bounded contexts
      1. Context maps
      2. Relationships between teams
      3. Anti-corruption layer
      4. Open host
      5. Aggregates
      6. Transactional boundary
      7. Aligned teams
      8. Iterative process
    11. Summary
    12. Questions
    13. Further reading
  10. Chapter 3: Microservices Architecture Pitfalls
    1. Layered architecture and its challenges
      1. Microservice architecture
    2. Over-architecting microservices
      1. Entity microservices
      2. The aggregator microservice
      3. Nanoservices
    3. Overusing frameworks and technologies
    4. Not abstracting common microservice tasks
      1. Dapr – LEGO® for microservices
    5. Lack of knowledge about the microservice platform
      1. Embracing containers
      2. Embracing the cloud-native approach
      3. Embracing micro platforms
    6. Neutralizing the benefits of microservices by adopting a frontend monolithic architecture
      1. Micro frontends
    7. Summary
    8. Questions
    9. Further reading
  11. Chapter 4: Keeping the Replatforming Brownfield Applications Trivial
    1. Not knowing the fundamentals when replatforming brownfield applications
      1. Why we should go for a microservice architecture
      2. Factors to consider when replatforming monolithic to a microservices architecture
      3. The decoupling approach
    2. Overlooking availability, reliability, and scalability when designing a microservices architecture
      1. Availability
      2. Reliability
      3. Scalability
    3. Sharing dependencies using older techniques
      1. Building self-contained services
      2. Reinventing is not an anti-pattern in microservices
    4. Summary
    5. Questions
    6. Further reading
  12. Section 2: Overview of Data Design Pitfalls, Communication, and Cross-Cutting Concerns
  13. Chapter 5: Data Design Pitfalls
    1. The pitfalls of keeping a single shared database
      1. Embracing polyglot persistence
    2. Normalizing read models
      1. Denormalizing read operations or keeping flat tables
    3. Understanding the CQRS principle
      1. Types of CQRS
      2. CQRS and microservices
      3. The problem we are trying to solve with CQRS
      4. The solution
      5. Challenges when implementing the CQRS pattern in our microservices
    4. The pitfalls of not knowing how to handle transactions
    5. Not choosing the right consistency and concurrency
      1. The choreography implementation of a saga
      2. The orchestration implementation of a saga
    6. Knowing how to perform reporting
      1. The API composition pattern
    7. Summary
    8. Questions
  14. Chapter 6: Communication Pitfalls and Prevention
    1. The fundamentals of microservices communication
      1. Synchronous versus asynchronous communication
      2. Messages and message types
      3. Asynchronous message-based communication
    2. Different architectures and their communication styles
    3. Direct client-to-microservice communication
      1. The API gateway pattern
    4. The overly complicated API gateway
      1. Multiple gateways – backends for the frontends
      2. Materialized view patterns
    5. Request timeout
      1. Retry patterns
      2. Circuit breaker patterns
    6. Long chains of synchronous calls – the retry storm
      1. Scalable infrastructure
      2. Load balancing, throttling, and request classifications
      3. Exponential backoff, jittering, and circuit breakers
      4. Only allowing the immediate layer to retry
    7. The dark side of event-driven microservices
      1. Event design pitfalls
    8. Avoiding service versioning
      1. Semantic versioning
      2. HTTP/REST API versioning approaches
      3. gRPC service versioning
      4. Event versioning
    9. Service meshes
    10. Dapr versus service meshes
    11. Summary
    12. Questions
    13. Further reading
  15. Chapter 7: Cross-Cutting Concerns
    1. Microservices chassis patterns
      1. Microservices application needs
    2. Cross-cutting pitfalls
      1. Embedding security handling inside microservices
      2. Not considering resiliency when building microservices
      3. Not considering idempotency when building microservices
      4. Embedding protocol translation inside microservices
      5. Message transformation coupling with microservices
      6. Directly exposing microservices to consumers
      7. Keeping configuration inside microservices
      8. Undiscoverable microservices
      9. Not maintaining a service template or framework
      10. Not paying attention to logging and monitoring
    3. Summary
    4. Questions
  16. Section 3: Testing Pitfalls and Evaluating Microservices Architecture
  17. Chapter 8: Deployment Pitfalls
    1. Failing to establish a deployment strategy
      1. Rolling deployment
      2. Canary deployment strategy
      3. A/B testing deployment strategy
      4. Blue/green deployment strategy
      5. Traffic shadowing deployment strategy
      6. Deploying Pods in Kubernetes
    2. Using outdated tools and technologies
    3. Failing to obtain cooperation from all teams
    4. Not considering Infrastructure as Code (IaC) for environment setup
    5. Not knowing the core principles of DevOps
      1. Feature management
      2. Agile practices
      3. Rollback strategy
      4. Using gates and approvals in Azure DevOps
    6. Deployment stamps pattern
    7. Deployment rings
    8. Geode pattern
    9. Summary
    10. Questions
  18. Chapter 9: Skipping Testing
    1. The shift-left testing strategy
      1. The testing pyramid
    2. Unit testing
      1. The unit testing life cycle
      2. Types of unit testing
      3. Scope of units
      4. Strategy
      5. Tools
      6. Frameworks and test maintenance
    3. End-to-end testing
      1. The two types of end-to-end testing
      2. White box and black box environments
      3. Journey testing
      4. Tools
    4. Integration testing
      1. Strategy
      2. Contract testing
      3. Tools
    5. Load testing
      1. Strategy
      2. Tools
    6. Summary
    7. Questions
    8. Further reading
  19. Chapter 10: Evaluating Microservices Architecture
    1. Identifying the core priorities of a business
    2. Managing architectural decisions
    3. Team structure
    4. Choosing the right methodology
    5. Decomposition strategy
    6. Evaluating the DevOps capability
    7. Understanding which part of the business is going to change more rapidly
    8. Infrastructure readiness
    9. Release cycles
    10. Communication protocol across services
    11. Exposing services to clients
    12. Distributed transaction handling
    13. Service development
    14. Capabilities of the hosting platform
    15. Deployment strategy
    16. Monitoring services
    17. Assigning a correlation token to each service request
    18. Defining a microservices chassis framework
    19. Shift-left approach for testing and security
    20. Summary
  20. Assessments
    1. Chapter 1: Setting Up Your Mindset for Microservices Endeavor
    2. Chapter 2: Failing to Understand the Role of DDD
    3. Chapter 3: Microservices Architecture Pitfalls
    4. Chapter 4: Keeping the Re-Platforming of Brownfield Applications Trivial
    5. Chapter 5: Data Design Pitfalls
    6. Chapter 6: Communication Pitfalls and Prevention
    7. Chapter 7: Cross-Cutting Concerns
    8. Chapter 8: Deployment Pitfalls
    9. Chapter 9: Skipping Testing
    10. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Embracing Microservices Design
  • Author(s): Ovais Mehboob Ahmed Khan, Nabil Siddiqui, Timothy Oleson, Mark Fussell
  • Release date: October 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781801818384