Hands-On Microservices – Monitoring and Testing
eBook - ePub

Hands-On Microservices – Monitoring and Testing

A performance engineer's guide to the continuous testing and monitoring of microservices

  1. 160 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Microservices – Monitoring and Testing

A performance engineer's guide to the continuous testing and monitoring of microservices

Book details
Book preview
Table of contents
Citations

About This Book

Learn and implement various techniques related to testing, monitoring and optimization for microservices architecture.

Key Features

  • Learn different approaches for testing microservices to design and implement, robust and secure applications
  • Become more efficient while working with microservices
  • Explore Testing and Monitoring tools such as JMeter, Ready API, and AppDynamics

Book Description

Microservices are the latest "right" way of developing web applications. Microservices architecture has been gaining momentum over the past few years, but once you've started down the microservices path, you need to test and optimize the services. This book focuses on exploring various testing, monitoring, and optimization techniques for microservices.

The book starts with the evolution of software architecture style, from monolithic to virtualized, to microservices architecture. Then you will explore methods to deploy microservices and various implementation patterns. With the help of a real-world example, you will understand how external APIs help product developers to focus on core competencies.

After that, you will learn testing techniques, such as Unit Testing, Integration Testing, Functional Testing, and Load Testing. Next, you will explore performance testing tools, such as JMeter, and Gatling. Then, we deep dive into monitoring techniques and learn performance benchmarking of the various architectural components. For this, you will explore monitoring tools such as Appdynamics, Dynatrace, AWS CloudWatch, and Nagios.

Finally, you will learn to identify, address, and report various performance issues related to microservices.

What you will learn

  • Understand the architecture of microservices and how to build services
  • Establish how external APIs help to accelerate the development process
  • Understand testing techniques, such as unit testing, integration testing, end-to-end testing, and UI/functional testing
  • Explore various tools related to the performance testing, monitoring, and optimization of microservices
  • Design strategies for performance testing
  • Identify performance issues and fine-tune performance

Who this book is for

This book is for developers who are involved with microservices architecture to develop robust and secure applications. Basic knowledge of microservices is essential in order to get the most out of this book.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Hands-On Microservices – Monitoring and Testing by Dinesh Rajput in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781789138405
Edition
1

Inter-Service Communication

In Chapter 1, Software Architecture Patterns, we learned about monolithic and microservice-based architectures and discussed their benefits and drawbacks. In Chapter 2, Anatomy of Microservice Decomposition Services, we looked at the various ways of decomposing a monolithic application into a microservice-based application, and we also built an application based on a microservice architecture. In chapter 3, Microservices Deployment Patterns, we discussed various strategies for deploying microservice-based applications. In this chapter, we will take a look at how the services within a system communicate with one another.
In a monolithic application, there is no need for inter-service communication or internal business functionality. The components invoke other components by calling a language-level method or through a simple function call. However, in the case of a microservice-based application, the components might not be part of the same service or machine. Instead, they might run on several machines or different clouds. Each service is typically a process, so you have to call other processes or services using various patterns to provide communication over different networks.
In this chapter, we will cover various inter-service communication strategies for either synchronous communication or asynchronous communication. We will also discuss Remote Procedure Invocations (RPIs), such as REST, gRPC, and Apache Thrift.
This chapter will cover the following topics:
  • Approaches to service communication:
    • Synchronous communication
    • Asynchronous communication
  • Messaging
  • Transactional messaging
  • Event-based communication
  • Microservice implementation patterns:
    • The Command Query Responsibility Segregation pattern (CQRS)
    • The Event Sourcing pattern
    • The Eventual Consistency pattern
  • Domain-specific protocols
Let’s get started and have a look at these topics in detail.

Approaches to service communication

In the microservice architecture pattern, a distributed system runs on several different machines, and each service is a component or process of an enterprise application. The services in these multiple machines must handle requests from the clients of the enterprise application. Sometimes, all of the services involved collaborate to handle such requests; the services interact using an inter-service communication mechanism.
However, in the case of a monolithic application, all components are part of the same application and run on the same machine. This means that the monolithic application doesn't require an inter-service communication mechanism. Have a look at the following diagram, which uses the Bookshop application from before and compares the two communication methods:
As you can see in the preceding diagram, a monolithic application has all of its components combined as a single artifact and deployed to a single machine. One component calls another using language-level method calls. However, in the microservice architecture, all components of the application run on multiple machines as a process or service and they use inter-process communication to interact with each other.
In the microservice architecture, there are two approaches to inter-process communication, which are as follows:
  • The synchronous communication style
  • The asynchronous communication style
Let's have a look at these communication styles in detail.

Synchronous communication

In this communication style, the client service expects a response within a period of time. It blocks the thread while it is waiting for a response from the server. This style can be used with HTTP protocols – usually REST. This is the easiest possible solution for inter-service communication. The client can make a REST call to interact with other services. The client sends a request to the server and waits for a response from the service (mostly using a JSON response over HTTP). Spring Cloud Netflix provides the most common pattern for synchronous REST communication such as Feign or Hystrix.
In the preceding diagram, the Order Service calls the Book Service and waits for the response to be returned. The Order Service can then process the Book Service's response in the same transaction that triggered the communication.
The synchronous communication approach does have some drawbacks, such as timeouts and strong coupling. For example, the Order Service needs to wait for the response from the Book Service, and the strong coupling means that the Order Service can't work without the Book Service being available. We can avoid this coupling by using the Hystrix library, which enables us to use fallbacks in case the service is not available at that time.
There are numerous protocols, such as REST, gRPC, and Apache Thrift, that can be used to interact with services synchronously.

REST

REST is an architectural style that describes best practices for exposing web services over HTTP. REpresentational State Transfer (REST), was coined by Roy Fielding. It is based on HTTP as an application protocol. REST is not just a means of transport, a framework, or specification, but instead is a style that emphasizes scalability.
Nowadays, RESTful is a popular style for developing APIs for enterprise application. REST is an architecture style and is used in the Inter-Process Communication (IPC) mechanism that uses HTTP. A resource is a key concept in REST architecture. It represents a business object such as an account or a customer; it can also represent a collection of business objects. In REST style, HTTP verbs are used as the actions for manipulating resources, and these actions are referenced using a URL.
REST services expose resources through URIs, such as the following: https://www.dineshonjava.com/book-shop/books/123456789. Resources support a limited set of operations such as GET, PUT, POST, and DELETE in the case of HTTP. All of these have well-defined semantics. For example, we can update the order PUT by calling /orders/123, but we can't update POST using /order/edit?id=123.
In REST services, clients can request a particular representation. Resources can support multiple representations, such as HTML, XML, or JSON, and representations of a resource can link to other resources. When using Hypermedia As The Engine of Application State (HATEOAS), the RESTful responses contain the links you need, just like HTML pages do.
RESTful services use a stateless architecture, so there is no HttpSession usage. The GET operations can be cached on URLs. REST provides looser coupling between the client and the server. HTTP headers and status codes communicate the result to clients.
REST provides a set of architectural constraints that, when applied as a whole, emphasize the scalability of component interactions, the generality of interfaces, independent deployment of components, and intermediary components to reduce interaction latency, enforce security, and encapsulate legacy systems.
– Roy Fielding, Architectural Styles and the Design of Network-based Software Architectures.
Let’s have a look at the following diagram, which explains what a synchronous REST call is:
In the preceding diagram, the ShopFrontUI web or mobile application requests a book order by making a POST request to the /book-order resource of the Ord...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. Packt Upsell
  5. Contributors
  6. Preface
  7. Software Architecture Patterns
  8. Anatomy of Microservice Decomposition Services
  9. Microservices Deployment Patterns
  10. Inter-Service Communication
  11. Service Registry and Discovery
  12. External API Gateway
  13. Testing of Microservices
  14. Performance Testing of Microservices
  15. Performance Monitoring of Microservices
  16. Other Books You May Enjoy