0%

Book Description

A practical, comprehensive, and user-friendly approach to building microservices in Spring

About This Book

  • Update existing applications to integrate reactive streams released as a part of Spring 5.0
  • Learn how to use Docker and Mesos to push the boundaries and build successful microservices
  • Upgrade the capability model to implement scalable microservices

Who This Book Is For

This book is ideal for Spring developers who want to build cloud-ready, Internet-scale applications, and simple RESTful services to meet modern business demands.

What You Will Learn

  • Familiarize yourself with the microservices architecture and its benefits
  • Find out how to avoid common challenges and pitfalls while developing microservices
  • Use Spring Boot and Spring Cloud to develop microservices
  • Handle logging and monitoring microservices
  • Leverage Reactive Programming in Spring 5.0 to build modern cloud native applications
  • Manage internet-scale microservices using Docker, Mesos, and Marathon
  • Gain insights into the latest inclusion of Reactive Streams in Spring and make applications more resilient and scalable

In Detail

The Spring Framework is an application framework and inversion of the control container for the Java platform. The framework’s core features can be used by any Java application, but there are extensions to build web applications on top of the Java EE platform.

This book will help you implement the microservice architecture in Spring Framework, Spring Boot, and Spring Cloud. Written to the latest specifications of Spring that focuses on Reactive Programming, you’ll be able to build modern, internet-scale Java applications in no time. The book starts off with guidelines to implement responsive microservices at scale. Next, you will understand how Spring Boot is used to deploy serverless autonomous services by removing the need to have a heavyweight application server.

Later, you’ll learn how to go further by deploying your microservices to Docker and managing them with Mesos. By the end of the book, you will have gained more clarity on the implementation of microservices using Spring Framework and will be able to use them in internet-scale deployments through real-world examples.

Style and approach

The book takes a step-by-step approach on developing microservices using Spring Framework, Spring Boot, and a set of Spring Cloud components that will help you scale your applications.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Demystifying Microservices
    1. Evolution of microservices
      1. Business demand as a catalyst for microservices evolution
      2. Technology as a catalyst for microservices evolution
      3. Imperative architecture evolution
    2. What are Microservices?
    3. Microservices - The honeycomb analogy
    4. Principles of microservices
      1. Single responsibility per service
      2. Microservices are autonomous
    5. Characteristics of microservices
      1. Services are first class citizens
        1. Characteristics of service in a microservice
      2. Microservices are lightweight
      3. Microservices with polyglot architecture
      4. Automation in microservices environment
      5. Microservices with a supporting ecosystem
      6. Microservices are distributed and dynamic
      7. Antifragility, fail fast, and self healing
    6. Microservices examples
      1. An example of a holiday portal
      2. An example of a travel agent portal
    7. Microservices benefits
      1. Supports polyglot architecture
      2. Enables experimentation and innovation
      3. Elastically and selectively scalable
      4. Allows substitution
      5. Enables to build organic systems
      6. Helps managing technology debt
      7. Allowing co-existence of different versions
      8. Supporting building self-organizing systems
      9. Supporting event-driven architecture
      10. Enables DevOps
    8. Summary
  3. Related Architecture Styles and Use Cases
    1. Service-Oriented Architecture (SOA)
      1. Service-oriented integration
      2. Legacy modernization
      3. Service-oriented application
      4. Monolithic migration using SOA
    2. Twelve-Factor Apps
      1. Single code base
      2. Bundle dependencies
      3. Externalizing configurations
      4. Backing services are addressable
      5. Isolation between build, release, and run
      6. Stateless, shared nothing processes
      7. Expose services through port bindings
      8. Concurrency for scale out
      9. Disposability, with minimal overhead
      10. Development, production parity
      11. Externalizing logs
      12. Package admin processes
    3. Serverless computing
    4. Lambda architecture
    5. DevOps, Cloud, and Containers
      1. DevOps as the practice and process for microservices
      2. Cloud and Containers as the self-service infrastructure for microservices
    6. Reactive microservices
      1. A reactive microservice-based order management system
    7. Microservice use cases
    8. Microservices early adopters - Is there a common theme?
      1. Monolithic migration as the common use case
    9. Microservice frameworks
    10. Summary
  4. Building Microservices with Spring Boot
    1. Setting up a development environment
    2. Spring Boot for building RESTful microservices
    3. Getting started with Spring Boot
    4. Developing a Spring Boot microservice
    5. Developing our first Spring Boot microservice
      1. Testing Spring Boot microservice
    6. HATEOAS-enabled Spring Boot microservice
    7. Reactive Spring Boot microservices
      1. Reactive microservices using Spring WebFlux
        1. Understanding Reactive Streams
          1. Publisher
          2. Subscriber
          3. Subscription
          4. Processor
      2. Reactive microservices using Spring Boot and RabbitMQ
    8. Implementing security
      1. Securing a microservice with basic security
      2. Securing microservice with OAuth2
    9. Enabling cross origin for microservices interactions
    10. Spring Boot actuators for microservices instrumentation
      1. Monitoring using JConsole
      2. Monitoring using ssh
      3. Adding a custom health module
      4. Building custom metrics
    11. Documenting microservices
    12. Putting it all together - Developing a customer registration microservice example
    13. Summary
  5. Applying Microservices Concepts
    1. Microservice design guidelines
      1. Deciding microservice boundaries
        1. Autonomous functions
        2. Size of the deployable unit
        3. Most appropriate function or sub-domain
        4. Polyglot architecture
        5. Selective scaling
        6. Agile teams and co-development
        7. Single responsibility
        8. Replicability or changeability
        9. Coupling and cohesion
        10. Think of the microservice as a product
      2. Designing communication styles
        1. Synchronous style communication
        2. Asynchronous style communication
        3. How to decide which style to choose?
      3. Orchestration of microservices
      4. How many endpoints - one or many?
      5. How many microservices per VM - one or multiple?
      6. Rules engine - shared or embedded?
      7. Role of BPM and workflows
      8. Can microservices share a data store?
      9. Can microservices be headless?
      10. Deciding transaction boundaries
        1. Altering use cases to simplify transactional requirements
        2. Distributed transaction scenarios
      11. Service endpoint design consideration
        1. Contract design
        2. Protocol selection
          1. Message oriented services
          2. HTTP and REST endpoints
          3. Optimized Communication Protocols
          4. API documentations
      12. Handling shared libraries
      13. User interfaces in microservices
      14. Use of API gateways in microservices
      15. Use of ESB and iPaaS with microservices
      16. Service versioning considerations
      17. Design for cross origin
      18. Handling shared reference data
      19. Microservices and bulk operations
    2. Summary
  6. Microservices Capability Model
    1. Microservices capability model
    2. Core capabilities
      1. Service listeners and libraries
      2. Storage capability
      3. Service implementation
      4. Service endpoint
    3. Infrastructure capabilities
      1. Cloud
      2. Container runtime
      3. Container orchestration
    4. Supporting capabilities
      1. Service gateway
      2. Software-defined load balancer
      3. Central log management
      4. Service discovery
      5. Security service
      6. Service configuration
      7. Ops monitoring
      8. Dependency management
      9. Data lake
      10. Reliable messaging
    5. Process and governance capabilities
      1. DevOps
      2. Automation tools
      3. Container registry
      4. Microservice documentation
      5. Reference architecture and libraries
    6. Microservices maturity model
      1. Level 0 - Traditional
      2. Level 1 - Basic
      3. Level 2 - Intermediate
      4. Level 3 - Advanced
    7. Entry points for adoption
    8. Summary
  7. Microservices Evolution – A Case Study
    1. Understanding the PSS application
      1. Business process view
      2. Functional view
      3. Architecture view
      4. Design view
      5. Implementation view
      6. Deployment view
    2. Death of the monolith
      1. Pain points
      2. Stopgap fix
      3. Retrospection
        1. Precedence on data sharing over modularity
        2. Single monolithic database
          1. Native queries
          2. Stored procedures
          3. Compromised on domain boundaries
    3. Microservices to the rescue - a planned approach for migration
      1. The business case
      2. Migration approach
      3. Identification of microservices' boundaries
      4. Analyze dependencies
        1. Events as opposed to query
        2. Events as opposed to synchronous updates
        3. Challenge requirements
        4. Challenge service boundaries
        5. Final dependency graph
      5. Prioritizing microservices for migration
      6. Data synchronization during migration
      7. Managing reference data
      8. User interfaces and web applications
        1. Session handling and security
      9. Test strategy
      10. Building ecosystem capabilities
      11. Migrate modules only if required
      12. Internal layering of microservices
      13. Orchestrating microservices
      14. Integration with other systems
      15. Managing shared libraries
      16. Handling exceptions
    4. Target implementation
      1. Implementation projects
      2. Running and testing the project
    5. Potential next steps
    6. Summary
  8. Scale Microservices with Spring Cloud Components
    1. What is Spring Cloud?
    2. Spring Cloud releases
    3. Setting up the environment for the BrownField PSS
    4. Spring Cloud Config
      1. Building microservices with Config Server
      2. Setting up the Config Server
      3. Understanding the Config Server URL
        1. Accessing the Config Server from clients
      4. Handling configuration changes
      5. Spring Cloud Bus for propagating configuration changes
      6. Setting up high availability for the Config Server
      7. Monitoring Config Server health
      8. Config Server for configuration files
      9. Completing changes to use Config Server
    5. Eureka for registration and discovery
      1. Understanding dynamic service registration and discovery
      2. Understanding Eureka
      3. Setting up the Eureka Server
      4. High availability for Eureka
    6. Zuul proxy as the API Gateway
      1. Setting up Zuul
      2. High availability of Zuul
        1. High availability of Zuul when the client is also a Eureka Client
        2. High availability when client is not a Eureka Client
        3. Completing Zuul for all other services
    7. Streams for reactive microservices
    8. Protecting microservices with Spring Cloud Security
    9. Summarising the BrownField PSS architecture
    10. Summary
  9. Logging and Monitoring Microservices
    1. Understanding log management challenges
    2. Centralized logging solution
    3. Selection of logging solutions
      1. Cloud services
      2. Off-the-shelf solutions
      3. Best of the breed integration
        1. Log shippers
        2. Log stream processors
        3. Log storage
        4. Dashboards
      4. Custom logging implementation
      5. Distributed tracing with Spring Cloud Sleuth
    4. Monitoring microservices
      1. Monitoring challenges
      2. Monitoring tools
      3. Monitoring microservice dependency
      4. Spring Cloud Hystrix for fault-tolerant microservices
      5. Aggregate Hystrix streams with Turbine
    5. Data analysis using Data Lake
    6. Summary
  10. Containerizing Microservices with Docker
    1. Understanding gaps in the BrownField PSS microservices
    2. What are containers?
    3. Difference between VM and containers
    4. Benefits of containers
    5. Microservices and containers
    6. Introduction to Docker
      1. Key components of Docker
        1. The Docker daemon
        2. The Docker client
        3. The Docker image
        4. The Docker container
        5. The Docker registry
        6. Dockerfile
    7. Deploying microservices into Docker
    8. Running RabbitMQ on Docker
    9. Using the Docker registry
      1. Setting up the Docker Hub
      2. Publish microservices to the Docker Hub
    10. Microservices on Cloud
      1. Installing Docker on AWS EC2
    11. Running BrownField services on EC2
    12. Future of containerization
    13. Summary
  11. Scaling Dockerized Microservices with Mesos and Marathon
    1. Scaling microservices
      1. Understanding autoscaling
      2. The missing pieces
    2. Container orchestration
      1. Why is container orchestration is important
      2. What does container orchestration do?
      3. Relationship with microservices
      4. Relationship with virtualization
      5. Container orchestration solutions
        1. Docker Swarm
        2. Kubernetes
        3. Apache Mesos
        4. HashiCorp Nomad
        5. CoreOS Fleet
    3. Container orchestration with Mesos and Marathon
      1. Mesos in details
        1. Mesos architecture
        2. Marathon
    4. Implementing Mesos and Marathon with DCOS
    5. Implementing Mesos and Marathon for BrownField microservices
      1. Installing Mesos, Marathon, and related components
      2. Running Mesos and Marathon
    6. Preparing BrownField PSS services
      1. Deploying BrownField PSS services
    7. Summary
  12. Microservice Development Life Cycle
    1. Practice points for microservice development
      1. Understanding business motivation and value
      2. Change the mindset from project to product development
      3. Choosing the right development philosophy
      4. Using the concept of minimum viable product (MVP)
      5. Overcoming the legacy hotspot
      6. Establishing self-organizing teams
      7. Building the self-service cloud
      8. Building a microservices ecosystem
      9. DevOps as a life cycle process
      10. Value driven planning
      11. Continuous monitoring and feedback
    2. Automating development cycle
      1. Development
      2. Integration
      3. Testing
        1. Sanity tests
        2. Regression testing
        3. Functional testing
        4. Acceptance testing
        5. Performance testing
        6. Real user flow simulation or Journey testing
        7. Security testing
        8. Exploratory testing
        9. A/B testing, Canary testing, and blue-green deployments
        10. Other non-functional tests
        11. Testing in production (TiP)
        12. Antifragility testing
      4. Deployment
      5. Monitoring and feedback
      6. Configuration management
      7. Microservices development governance, reference architectures, and libraries
    3. Summary
35.169.107.177