O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Microservices: Building Scalable Software

Book Description

Discover how to easily build and implement scalable microservices from scratch

About This Book

  • Build, deploy, and test microservices from scratch with ease
  • Learn how to efficiently build and implement microservices in Spring, and how to use Docker and Mesos to push the boundaries of what you thought possible
  • Master the architecture of Mesos and intelligently distribute your task across clusters of machines

Who This Book Is For

This course is intended for Java and Spring developers, DevOps engineers, and system administrators who are familiar with microservice architecture and have a good understanding of the core elements and microservice applications but now want to delve into effectively implementing microservices at the enterprise level.

What You Will Learn

  • Use a domain-driven approach to design and implement microservices
  • Secure microservices using Spring Security
  • Deploy and test microservices
  • Use Spring Boot to develop microservices
  • Find out how to avoid common pitfalls when developing microservices
  • Familiarize yourself with end-to-end microservices written in Spring Framework and Spring Boot
  • Understand the Mesos architecture
  • Deploy a multi-node Mesos cluster using your favorite DevOps

In Detail

Microservices are the next big thing in designing scalable, easy-to-maintain applications, making app development easier and providing great flexibility in utilizing various resources optimally.

This course is divided into three modules and each module is a mini-course in its own right, helping you enhance your knowledge.

Starting off with the first module, you will understand the core concepts and frameworks of microservice architecture. You will then learn how to set up the development environment and configure it before implementing continuous integration to deploy your microservice architecture. You will learn to secure microservices and test them effectively using REST Java clients and other tools. Finally, you will build smaller, lighter, and faster services that can be implemented easily.

The second module will help you implement the microservice architecture in Spring Framework, Spring Boot, and Spring Cloud. With the latest specifications of Spring, you'll be able to build modern, Internet-scale Java applications in no time. You'll delve into Spring Boot, Spring Cloud, Docker, Mesos, and Marathon, and understand how to deploy autonomous services without using heavy-weight application servers. By the end, you'll have a good grasp of Spring Framework and how to implement microservices using it.

In the last module of this course, you will learn about Apache Mesos, open source, cluster-management software that provides efficient resource isolations and sharing. This advanced module will show you how to deploy important, big data processing frameworks such as Hadoop, Spark, and Storm on Mesos and big data storage frameworks such as Cassandra, Elasticsearch, and Kafka.

This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

  • Mastering Microservices with Java, Sourabh Sharma
  • Spring Microservices, Rajesh RV
  • Mastering Mesos, Dipa Dubhashi Akhil Das

Style and approach

This course follows a step-by-step approach that teaches readers to build smaller, lighter, and faster services that can be implemented easily in a production environment.

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. Microservices: Building Scalable Software
    1. Table of Contents
    2. Microservices: Building Scalable Software
    3. Microservices: Building Scalable Software
    4. Credits
    5. Preface
      1. What this learning path covers
      2. What you need for this learning path
      3. Who this learning path is for
      4. Reader feedback
      5. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    6. 1. Module 1
      1. 1. A Solution Approach
        1. Evolution of µServices
        2. Monolithic architecture overview
        3. Limitation of monolithic architecture versus its solution with µServices
          1. One dimension scalability
          2. Release rollback in case of failure
          3. Problems in adopting new technologies
          4. Alignment with Agile practices
          5. Ease of development – could be done better
          6. Microservices build pipeline
          7. Deployment using a container such as Docker
            1. Containers
            2. Docker
            3. Docker's architecture
              1. Docker image
            4. Docker container
            5. Deployment
        4. Summary
      2. 2. Setting Up the Development Environment
        1. Spring Boot configuration
          1. Spring Boot overview
          2. Adding Spring Boot to the rest sample
          3. Adding a Jetty-embedded server
        2. Sample REST program
          1. Writing the REST controller class
            1. @RestController
            2. @RequestMapping
            3. @RequestParam
            4. @PathVariable
          2. Making a sample REST app executable
        3. Setting up the application build
          1. Running the Maven tool
          2. Executing with the Java command
        4. REST API testing using the Postman Chrome extension
          1. Some more positive test scenarios
          2. Negative test scenarios
        5. NetBeans IDE installation and setup
        6. References
        7. Summary
      3. 3. Domain-Driven Design
        1. Domain-driven design fundamentals
        2. Building blocks
          1. Ubiquitous language
          2. Multilayered architecture
            1. Presentation layer
            2. Application layer
            3. Domain layer
            4. Infrastructure layer
          3. Artifacts of domain-driven design
            1. Entities
            2. Value objects
              1. Frequently asked questions
            3. Services
            4. Aggregates
            5. Repository
            6. Factory
            7. Modules
        3. Strategic design and principles
          1. Bounded context
          2. Continuous integration
          3. Context map
            1. Shared kernel
            2. Customer-supplier
            3. Conformist
            4. Anticorruption layer
            5. Separate ways
            6. Open host service
            7. Distillation
        4. Sample domain service
          1. Entity implementation
          2. Repository implementation
          3. Service implementation
        5. Summary
      4. 4. Implementing a Microservice
        1. OTRS overview
        2. Developing and implementing µServices
          1. Restaurant µService
            1. Controller class
              1. API versioning
            2. Service classes
            3. Repository classes
            4. Entity classes
          2. Booking and user services
          3. Registration and Discovery service (Eureka service)
          4. Execution
        3. Testing
        4. References
        5. Summary
      5. 5. Deployment and Testing
        1. An overview of microservice architecture using Netflix OSS
        2. Load balancing
          1. Client-side load balancing
          2. Server-side load balancing
        3. Circuit breaker and monitoring
          1. Using Hystrix's fallback methods
          2. Monitoring
          3. Setting up the Hystrix Dashboard
          4. Setting up Turbine
        4. Microservice deployment using containers
          1. Installation and configuration
            1. Docker Machine with 4 GB
            2. Building Docker images with Maven
            3. Running Docker using Maven
            4. Integration testing with Docker
            5. Pushing the image to a registry
            6. Managing Docker containers
        5. References
        6. Summary
      6. 6. Securing Microservices
        1. Enabling Secure Socket Layer
        2. Authentication and authorization
          1. OAuth 2.0
            1. Usage of OAuth
          2. OAuth 2.0 specification – concise details
            1. OAuth 2.0 roles
              1. Resource owner
              2. Resource server
              3. Client
              4. Authorization server
            2. OAuth 2.0 client registration
              1. Client types
                1. Confidential client type
                2. Public client type
                3. Web application
                4. User agent-based application
                5. Native application
              2. Client identifier
              3. Client authentication
            3. OAuth 2.0 protocol endpoints
              1. Authorization endpoint
              2. Token endpoint
              3. Redirection endpoint
            4. OAuth 2.0 grant types
              1. Authorization code grant
                1. Authorization code requests and responses
              2. Implicit grant
                1. Implicit grant requests and responses
              3. Resource owner password credentials grant
              4. Client credentials grant
        3. OAuth implementation using Spring Security
          1. Authorization code grant
          2. Implicit grant
          3. Resource owner password credential grant
          4. Client credentials grant
        4. References
        5. Summary
      7. 7. Consuming Services Using a Microservice Web App
        1. AngularJS framework overview
          1. MVC
          2. MVVM
          3. Modules
          4. Providers and services
          5. Scopes
          6. Controllers
          7. Filters
          8. Directives
          9. UI-Router
        2. Development of OTRS features
          1. Home page/restaurant list page
            1. index.html
            2. app.js
            3. restaurants.js
            4. restaurants.html
          2. Search Restaurants
          3. Restaurant details with reservation option
            1. restaurant.html
          4. Login page
            1. login.html
            2. login.js
          5. Reservation confirmation
        3. Setting up the web app
        4. Summary
      8. 8. Best Practices and Common Principles
        1. Overview and mindset
        2. Best practices and principals
          1. Nanoservice (not recommended), size, and monolithic
          2. Continuous integration and deployment
          3. System/end-to-end test automation
          4. Self-monitoring and logging
          5. A separate data store for each microservice
          6. Transaction boundaries
        3. Microservices frameworks and tools
          1. Netflix Open Source Software (OSS)
            1. Build – Nebula
            2. Deployment and delivery – Spinnaker with Aminator
            3. Service registration and discovery – Eureka
            4. Service communication – Ribbon
            5. Circuit breaker – Hystrix
            6. Edge (proxy) server – Zuul
            7. Operational monitoring – Atlas
            8. Reliability monitoring service – Simian Army
            9. AWS resource monitoring – Edda
            10. On-host performance monitoring – Vector
            11. Distributed configuration management – Archaius
            12. Scheduler for Apache Mesos – Fenzo
            13. Cost and cloud utilization – Ice
            14. Other security tools – Scumblr and FIDO
              1. Scumblr
              2. Fully Integrated Defence Operation (FIDO)
        4. References
        5. Summary
      9. 9. Troubleshooting Guide
        1. Logging and ELK stack
          1. A brief overview
            1. Elasticsearch
            2. Logstash
            3. Kibana
          2. ELK stack setup
            1. Installing Elasticsearch
            2. Installing Logstash
            3. Installing Kibana
              1. Tips for ELK stack implementation
        2. Use of correlation ID for service calls
          1. Let's see how we can tackle this problem
        3. Dependencies and versions
          1. Cyclic dependencies and their impact
            1. It needs to be analyzed while designing the system
          2. Maintaining different versions
          3. Let's explore more
        4. References
        5. Summary
    7. 2. Module 2
      1. 1. Demystifying Microservices
        1. The evolution of microservices
          1. Business demand as a catalyst for microservices evolution
          2. Technology as a catalyst for the 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 services in a microservice
          2. Microservices are lightweight
          3. Microservices with polyglot architecture
          4. Automation in a 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. A microservice-based order management system
          3. An example of a travel agent portal
        7. Microservices benefits
          1. Supports polyglot architecture
          2. Enabling experimentation and innovation
          3. Elastically and selectively scalable
          4. Allowing substitution
          5. Enabling to build organic systems
          6. Helping reducing technology debt
          7. Allowing the coexistence of different versions
          8. Supporting the building of self-organizing systems
          9. Supporting event-driven architecture
          10. Enabling DevOps
        8. Relationship with other architecture styles
          1. Relations with SOA
            1. Service-oriented integration
            2. Legacy modernization
            3. Service-oriented application
            4. Monolithic migration using SOA
          2. Relations with Twelve-Factor apps
            1. A single code base
            2. Bundling dependencies
            3. Externalizing configurations
            4. Backing services are addressable
            5. Isolation between build, release, and run
            6. Stateless, shared nothing processes
            7. Exposing services through port bindings
            8. Concurrency to scale out
            9. Disposability with minimal overhead
            10. Development and production parity
            11. Externalizing logs
            12. Package admin processes
        9. Microservice use cases
          1. Microservices early adopters
          2. The common theme is monolithic migrations
        10. Summary
      2. 2. Building Microservices with Spring Boot
        1. Setting up a development environment
        2. Developing a RESTful service – the legacy approach
        3. Moving from traditional web applications to microservices
        4. Using Spring Boot to build RESTful microservices
        5. Getting started with Spring Boot
        6. Developing the Spring Boot microservice using the CLI
        7. Developing the Spring Boot Java microservice using STS
          1. Examining the POM file
          2. Examining Application.java
          3. Examining application.properties
          4. Examining ApplicationTests.java
          5. Testing the Spring Boot microservice
        8. Developing the Spring Boot microservice using Spring Initializr – the HATEOAS example
        9. What's next?
        10. The Spring Boot configuration
          1. Understanding the Spring Boot autoconfiguration
          2. Overriding default configuration values
          3. Changing the location of the configuration file
          4. Reading custom properties
          5. Using a .yaml file for configuration
          6. Using multiple configuration profiles
          7. Other options to read properties
        11. Changing the default embedded web server
        12. Implementing Spring Boot security
          1. Securing microservices with basic security
          2. Securing a microservice with OAuth2
        13. Enabling cross-origin access for microservices
        14. Implementing Spring Boot messaging
        15. Developing a comprehensive microservice example
        16. Spring Boot actuators
          1. Monitoring using JConsole
          2. Monitoring using SSH
        17. Configuring application information
        18. Adding a custom health module
          1. Building custom metrics
        19. Documenting microservices
        20. Summary
      3. 3. Applying Microservices Concepts
        1. Patterns and common design decisions
          1. Establishing appropriate microservice boundaries
            1. Autonomous functions
            2. Size of a deployable unit
            3. Most appropriate function or subdomain
            4. Polyglot architecture
            5. Selective scaling
            6. Small, agile teams
            7. Single responsibility
            8. Replicability or changeability
            9. Coupling and cohesion
            10. Think 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 in a microservice?
          5. One microservice per VM or multiple?
          6. Rules engine – shared or embedded?
          7. Role of BPM and workflows
          8. Can microservices share data stores?
          9. Setting up transaction boundaries
            1. Altering use cases to simplify transactional requirements
            2. Distributed transaction scenarios
          10. 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
          11. Handling shared libraries
          12. User interfaces in microservices
          13. Use of API gateways in microservices
          14. Use of ESB and iPaaS with microservices
          15. Service versioning considerations
          16. Design for cross origin
          17. Handling shared reference data
          18. Microservices and bulk operations
        2. Microservices challenges
          1. Data islands
          2. Logging and monitoring
          3. Dependency management
          4. Organization culture
          5. Governance challenges
          6. Operation overheads
          7. Testing microservices
          8. Infrastructure provisioning
        3. The microservices capability model
          1. Core capabilities
          2. Infrastructure capabilities
          3. Supporting capabilities
          4. Process and governance capabilities
        4. Summary
      4. 4. Microservices Evolution – A Case Study
        1. Reviewing the microservices capability model
        2. Understanding the PSS application
          1. Business process view
          2. Functional view
          3. Architectural view
          4. Design view
          5. Implementation view
          6. Deployment view
        3. Death of the monolith
          1. Pain points
          2. Stop gap fix
          3. Retrospection
            1. Shared data
            2. Single database
              1. Native queries
              2. Stored procedures
            3. Domain boundaries
        4. Microservices to the rescue
        5. The business case
        6. Plan the evolution
          1. Evolutionary approach
          2. Identification of microservices boundaries
            1. 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
          3. Prioritizing microservices for migration
          4. Data synchronization during migration
          5. Managing reference data
          6. User interfaces and web applications
            1. Session handling and security
          7. Test strategy
          8. Building ecosystem capabilities
        7. Migrate modules only if required
        8. Target architecture
          1. Internal layering of microservices
          2. Orchestrating microservices
          3. Integration with other systems
          4. Managing shared libraries
          5. Handling exceptions
        9. Target implementation view
          1. Implementation projects
          2. Running and testing the project
        10. Summary
      5. 5. Scaling Microservices with Spring Cloud
        1. Reviewing microservices capabilities
        2. Reviewing BrownField's PSS implementation
        3. What is Spring Cloud?
          1. Spring Cloud releases
          2. Components of Spring Cloud
            1. Spring Cloud and Netflix OSS
        4. Setting up the environment for BrownField PSS
        5. Spring Cloud Config
          1. What's next?
          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 the Config server health
          8. Config server for configuration files
          9. Completing changes to use the Config server
        6. Feign as a declarative REST client
        7. Ribbon for load balancing
        8. 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
        9. 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 the client is not a Eureka client
          3. Completing Zuul for all other services
        10. Streams for reactive microservices
        11. Summarizing the BrownField PSS architecture
        12. Summary
      6. 6. Autoscaling Microservices
        1. Reviewing the microservice capability model
        2. Scaling microservices with Spring Cloud
        3. Understanding the concept of autoscaling
          1. The benefits of autoscaling
          2. Different autoscaling models
            1. Autoscaling an application
            2. Autoscaling the infrastructure
          3. Autoscaling in the cloud
        4. Autoscaling approaches
          1. Scaling with resource constraints
          2. Scaling during specific time periods
          3. Scaling based on the message queue length
          4. Scaling based on business parameters
          5. Predictive autoscaling
        5. Autoscaling BrownField PSS microservices
          1. The capabilities required for an autoscaling system
          2. Implementing a custom life cycle manager using Spring Boot
          3. Understanding the deployment topology
          4. Understanding the execution flow
          5. A walkthrough of the life cycle manager code
          6. Running the life cycle manager
        6. Summary
      7. 7. Logging and Monitoring Microservices
        1. Reviewing the microservice capability model
        2. Understanding log management challenges
        3. A centralized logging solution
        4. The selection of logging solutions
          1. Cloud services
          2. Off-the-shelf solutions
          3. Best-of-breed integration
            1. Log shippers
            2. Log stream processors
            3. Log storage
            4. Dashboards
          4. A custom logging implementation
          5. Distributed tracing with Spring Cloud Sleuth
        5. Monitoring microservices
          1. Monitoring challenges
          2. Monitoring tools
          3. Monitoring microservice dependencies
          4. Spring Cloud Hystrix for fault-tolerant microservices
          5. Aggregating Hystrix streams with Turbine
        6. Data analysis using data lakes
        7. Summary
      8. 8. Containerizing Microservices with Docker
        1. Reviewing the microservice capability model
        2. Understanding the gaps in BrownField PSS microservices
        3. What are containers?
        4. The difference between VMs and containers
        5. The benefits of containers
        6. Microservices and containers
        7. Introduction to Docker
          1. The key components of Docker
            1. The Docker daemon
            2. The Docker client
          2. Docker concepts
            1. Docker images
            2. Docker containers
            3. The Docker registry
            4. Dockerfile
        8. Deploying microservices in Docker
        9. Running RabbitMQ on Docker
        10. Using the Docker registry
          1. Setting up the Docker Hub
          2. Publishing microservices to the Docker Hub
        11. Microservices on the cloud
          1. Installing Docker on AWS EC2
        12. Running BrownField services on EC2
        13. Updating the life cycle manager
        14. The future of containerization – unikernels and hardened security
        15. Summary
      9. 9. Managing Dockerized Microservices with Mesos and Marathon
        1. Reviewing the microservice capability model
        2. The missing pieces
        3. Why cluster management is important
        4. What does cluster management do?
        5. Relationship with microservices
        6. Relationship with virtualization
        7. Cluster management solutions
          1. Docker Swarm
          2. Kubernetes
          3. Apache Mesos
          4. Nomad
          5. Fleet
        8. Cluster management with Mesos and Marathon
          1. Diving deep into Mesos
            1. The Mesos architecture
            2. Marathon
        9. Implementing Mesos and Marathon for BrownField microservices
          1. Setting up AWS
          2. Installing ZooKeeper, Mesos, and Marathon
            1. Configuring ZooKeeper
            2. Configuring Mesos
            3. Running Mesos, Marathon, and ZooKeeper as services
              1. Running the Mesos slave in the command line
            4. Preparing BrownField PSS services
            5. Deploying BrownField PSS services
            6. Reviewing the deployment
        10. A place for the life cycle manager
          1. Rewriting the life cycle manager with Mesos and Marathon
        11. The technology metamodel
        12. Summary
      10. 10. The Microservices Development Life Cycle
        1. Reviewing the microservice capability model
        2. The new mantra of lean IT – DevOps
          1. Reducing wastage
          2. Automating every possible step
          3. Value-driven delivery
          4. Bridging development and operations
        3. Meeting the trio – microservices, DevOps, and cloud
          1. Cloud as the self-service infrastructure for Microservices
          2. DevOps as the practice and process for microservices
        4. Practice points for microservices development
          1. Understanding business motivation and value
          2. Changing the mindset from project to product development
          3. Choosing a development philosophy
            1. Design thinking
            2. The start-up model
            3. The Agile practice
          4. Using the concept of Minimum Viable Product
          5. Overcoming the legacy hotspot
          6. Addressing challenges around databases
          7. Establishing self-organizing teams
          8. Building a self-service cloud
          9. Building a microservices ecosystem
          10. Defining a DevOps-style microservice life cycle process
            1. Value-driven planning
            2. Agile development
            3. Continuous integration
            4. Continuous testing
            5. Continuous release
            6. Continuous monitoring and feedback
          11. Automating the continuous delivery pipeline
            1. Development
            2. Continuous integration
            3. Automated testing
              1. Different candidate tests for automation
                1. Automated sanity tests
                2. Regression testing
                3. Automated functional testing
                4. Automated acceptance testing
                5. Performance testing
                6. Real user flow simulation or journey testing
                7. Automated security testing
                8. Exploratory testing
                9. A/B testing, canary testing, and blue-green deployments
                10. Other nonfunctional tests
                11. Testing in production
                12. Antifragility testing
              2. Target test environments
            4. Continuous deployment
            5. Monitoring and feedback
          12. Automated configuration management
        5. Microservices development governance, reference architectures, and libraries
        6. Summary
    8. 3. Module 3
      1. 1. Microservices Architecture
        1. Need for microservices
          1. Monolithic software
          2. Microservices in the real world
          3. Microservice-oriented architectures
          4. How is it better?
          5. Shortcomings
        2. Key design principles
          1. Business units, no components
          2. Smart services, dumb communication pipes
          3. Decentralization
          4. Technology alignment
          5. How small is too small?
        3. Key benefits
          1. Resilience
          2. Scalability
          3. Technology heterogeneity
          4. Replaceability
          5. Independence
            1. Why is replaceability important?
            2. Easy to deploy
        4. SOA versus microservices
        5. Why Node.js?
          1. API aggregation
          2. The future of Node.js
        6. Summary
      2. 2. Microservices in Node.js – Seneca and PM2 Alternatives
        1. Need for Node.js
          1. Installing Node.js, npm, Seneca, and PM2
            1. Learning npm
          2. Our first program – Hello World
          3. Node.js threading model
          4. Modular organization best practices
            1. Javascript
            2. SOLID design principles
        2. Seneca – a microservices framework
          1. Inversion of control done right
          2. Pattern matching in Seneca
            1. Patrun – a pattern-matching library
            2. Reusing patterns
            3. Writing plugins
            4. Web server integration
              1. Seneca as Express middleware
              2. Data storage
        3. PM2 – a task runner for Node.js
          1. Single-threaded applications and exceptions
          2. Using PM2 – the industry-standard task runner
        4. Summary
      3. 3. From the Monolith to Microservices
        1. First, there was the monolith
          1. How to tackle organic growth?
          2. How abstract is too abstract?
        2. Then the microservices appeared
          1. Disadvantages
          2. Splitting the monolith
          3. Problems splitting the monolith – it is all about the data
        3. Organizational alignment
        4. Summary
      4. 4. Writing Your First Microservice in Node.js
        1. Micromerce – the big picture
        2. Product Manager – the two-faced core
          1. Fetching products
          2. Fetching by category
          3. Fetching by ID
          4. Adding a product
          5. Removing a product
          6. Editing a product
          7. Wiring everything up
          8. Integrating with Express – how to create a REST API
        3. The e-mailer – a common problem
          1. How to send e-mails
          2. Defining the interface
          3. Setting up Mandrill
          4. Hands on – integrating Mandrill in your microservice
          5. The fallback strategy
        4. The order manager
          1. Defining the microservice – how to gather non-local data
          2. The order manager – the code
            1. Calling remote services
            2. Resilience over perfection
        5. The UI – API aggregation
          1. Need for frontend microservice
          2. The code
          3. Service degradation – when the failure is not a disaster
          4. Circuit breakers
          5. Seneca – a simple puzzle that makes our lives easier
          6. Seneca and promises
        6. Debugging
        7. Summary
      5. 5. Security and Traceability
        1. Infrastructure logical security
          1. SSH – encrypting the communications
        2. Application security
          1. Common threats – how to be up to date
            1. Injection
              1. Input validation
            2. Cross-site scripting
              1. Output encoding
            3. Cross-site request forgery
            4. Open redirects
          2. Effective code reviews
        3. Traceability
          1. Logging
          2. Tracing requests
          3. Auditing
          4. HTTP codes
            1. 1xx – informational
            2. 2xx – success codes
            3. 3xx – redirection
            4. 4xx – client errors
            5. 5xx – server errors
            6. Why HTTP codes matter in microservices
        4. Summary
      6. 6. Testing and Documenting Node.js Microservices
        1. Functional testing
          1. The pyramid of automated testing
            1. Unit tests
            2. Integration tests
            3. End-to-end tests
            4. How much testing is too much?
          2. Testing microservices in Node.js
            1. Chai
              1. BDD-style interfaces
              2. Assertions interface
            2. Mocha
            3. Sinon.JS – a mocking framework
            4. Testing a real microservice
              1. TDD – Test-driven development
              2. Unit testing
              3. End-to-end testing
            5. Manual testing – the necessary evil
              1. Building a proxy to debug our microservices
              2. Postman
        2. Documenting microservices
          1. Documenting APIs with Swagger
          2. Generating a project from the Swagger definition
        3. Summary
      7. 7. Monitoring Microservices
        1. Monitoring services
          1. Monitoring using PM2 and Keymetrics
            1. Diagnosing problems
            2. Monitoring application exceptions
            3. Custom metrics
              1. Simple metric
              2. Counter
              3. Average calculated values
        2. Simian Army – the active monitoring from Spotify
          1. Throughput and performance degradation
        3. Summary
      8. 8. Deploying Microservices
        1. Concepts in software deployment
          1. Continuous integration
          2. Continuous delivery
        2. Deployments with PM2
          1. PM2 – ecosystems
          2. Deploying microservices with PM2
            1. Configuring the server
        3. Docker – a container for software delivery
          1. Setting up the container
            1. Installing Docker
            2. Choosing the image
            3. Running the container
            4. Installing the required software
            5. Saving the changes
          2. Deploying Node.js applications
          3. Automating Docker container creation
        4. Node.js event loop – easy to learn and hard to master
        5. Clustering Node.js applications
        6. Load balancing our application
          1. Health check on NGINX
            1. Passive health check
            2. Active health check
        7. Summary
    9. A. Bibliography
    10. Index