Performance Patterns In Microservices Based Integrations

Rohit Dhall_Profile_Pic (2)

Rohit Dhall


Microservices architecture based systems are becoming more and more popular in IT environments. Integration of different components and services/applications, are an integral part of any application and systems. Almost all applications, which perform anything useful for a given business, need to be integrated with one or more applications .But this integration also presents huge challenges with respect to performance of the overall integrated system. With microservices based architecture, where number of services are broken down based on the services or functionality these microservices offer, count of integration points or touch points increase by huge numbers. This in turn increase the performance challenges, which can impact the overall working of the system. This article discusses some of the key performance challenges which can impact the performance of microservices based systems. It also present some techniques and patterns, which can be used to avoid these challenges.


1. Performance Challenges with respect to integrated systems

Distributed computing has its own challenges and all of these challenges are not only well documented, but also are experienced by professionals working on distributed systems almost daily.With the number of touch points likely to be much higher than a ‘normal’ integration scenario, things can get real ugly. While connecting to other microservices (within the same bounded context or of some remote, external system), lot of things can go wrong. Microservices being connected to may be slow or down.If our application is not designed to handle this scenario gracefully, it can have adverse impact on the performance and stability of our application.

2. Mitigation of performance challenges

In this section we will talk about some approaches and design decisions, which can help us achieve better performance, resilience and overall stability w.r.t. integration challenges in a microservices based environment.

2.1 Throttling

Throttling is one technique which can be used to avoid any misbehaving or rouge application, from overloading or bringing down our application, by sending more requests than what our application can handle.

One simple way to implement throttling is by providing fixed number of connections to individual applications. Consider there are two vendors who call our microservice to deduct money from one account. If one vendor is a big application like say Amazon, then it is likely to consume our service more often than say a vendor which has a small user base. So we can provide these two vendors two separate and dedicated ‘entry point’ with dedicated throttled connection limit. This way large number of requests coming from Amazon will not hamper requests coming from second vendor. Moreover, we can throttle individual partners so that none can send requests at a rate faster than what we can process.

Generally, synchronous requests from external services/systems are throttled at load balancer/HTTP server or other such entry point.

1.1     Timeouts

If a microservices being invoked, is responding slow, this can cause our application to take longer time to complete a request. Application threads now remain busy for longer duration. This can have cascading impact on our application, resulting in application/server becoming totally chocked/unresponsive.


Most of the libraries/APIs/frameworks and servers provide configurable settings for specifying different kind of timeouts. You may need to set timeouts for read requests/write requests/wait timeouts/connection pool wait timeouts/keep alive timeouts and so on. Values of these timeouts should be determined only by proper performance testing/SLA validation etc.

1.2     Dedicated Thread Pools/Bulkheads

Another important design decision is to have separate dedicated thread pools for different tasks or for connecting to different microservices. Consider a scenario where, in your application flow, you need to connect to five different microservices using REST over HTTP. You are also using a library to use common thread pool for maintaining these connections. If for some reason, one of the five services starts misbehaving by responding slow, then all your pool members will be exhausted, while waiting for the response from this service. To minimize the impact, it is always a good practice to have dedicated pool for individual service. This can minimize the impact caused by a misbehaving service, thus allowing your application to continue with other parts of execution path.

This pattern is commonly known as Bulkheads. Following figure depicts a sample scenario of implementing bulkhead. On the left hand side, Microservice A, which is calling both microservice X and microservice Y, is using single common pool to connect to these microservices.If either one of service X or service Y is misbehaving, this can impact the overall behavior of the flow, as connection pool is common. If instead bulkhead is implemented, as shown in the right side of the figure, even if say microservice X is misbehaving, pool for X will be impacted. Application can continue to offer functionality which depend on microservice Y.


1.3     Circuit Breakers

Circuit Breaker is a design pattern, which is used to minimize the impact of any of the downstream being not accessible or down (due to planned or unplanned outages).Circuit breakers are used to check the availability of external systems/services, and in case these are down, application can be prevented from sending requests to these external systems.This act as a safety measure, on top of timeouts/bulkheads, where one may not want to even wait for the period specified by timeout.If a downstream system is down, it is of no use to wait for the TIMEOUT period for each request, and then getting a response of timeout exception. Instead, requests should not even try to connect to these systems, during the time, when these are down.

Circuit breakers can have built in logic to perform necessary healthcheck of external systems, and start forwarding the requests, once these systems are up and working fine.

1.4     Asynchronous Integration

Most of the performance issues related to integrations can be avoided by decoupling the communications between microservices. Asynchronous integration approach provides one such mechanism to achieve this decoupling. Take a look at design of your microservices based system, and give it a serious thought if you see point to point integration between two microservices.

Any standard message broker systems can be used to provide publish subscribe capabilities.

2.     Conclusion

In this paper, we talked about some of the performance challenges, which are faced, while integrating microservices based systems.It also presented some patterns which can be used to designing systems, to avoid these performance issues.We discussed throttling,timeout,bulkheads and circuit breaker patterns. Apart from these, asynchronous integration approach is also discussed.

In a nutshell, asynchronous integration should be preferred, wherever possible. Other patterns, should be used in integration scenarios, to avoid the ripple/cascading side effect of a misbehaving downstream system.

About the author

Rohit Dhall is working as Enterprise Architect with Engineering And R & D Services,HCL Technologies. His main area of expertise is architecting, designing and implementing high performance and highly available solutions for global clients in Telco and BFSI domain.He has worked on diverse technologies like java/J2ee,client server,P2P ,DWH etc.He is a coauthor of IBM Redbook and Redpaper on ‘ITCAM for WebSphere’.








Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top