Challenges in microservices

 

What is a microservice?

Microservices is an architectural pattern that defines how a single application consists of capabilities such as loose coupling and autonomy between many services or components. These autonomous services are deployable and have their own stack of technology. The ability to have their own data management model and communicate over REST APIs gives microservices an edge. The code of these microservices can be easily updatable and can be scaled independently.

In the argument of monolithic vs. microservices architecture, the monolithic is a tightly coupled single unified unit of an application that makes it challenging to do code changes. Also, the monolithic architecture makes it harder to understand when it comes to scaling and managing while scaling up. If a new technology must be introduced, then the whole application must be rewritten. Independent components, easier scaling, and better understandability make the microservices the clear winner here.

 

Challenges in microservices

Even though microservices architecture is a widely popular and used architectural pattern with the emergence of the latest technologies, there are challenges in different categories in the development lifecycle.

 

Development

The development of microservices has its common issues, such as using different technologies by different teams. Different styles and frameworks make it complex when trying to collaborate within teams. Using different architectural patterns also makes it difficult when it comes to communicating across different teams.

In the development stages, the choosing of the architectural pattern has its benefits as well as challenges. Using the “Gateway” pattern is challenging and costly in terms of infrastructure. You need to have an Enterprise Service Bus (ESB), a client load balancer, and a discovery service. And if the “Database per service” pattern is selected, each service should have its own database management. This raises the issues of communicating with multiple databases to execute a particular transaction and data redundancy by having duplicate data in different databases of the different services. If you introduce APIs for each of these services to access its data, there is an increased development time and effort to be considered.

 

Deployment

The deployment of each microservices should be handled independently, which is a tedious task for any deployment team. The coordination of multiple services should also be looked at as there can be dependencies. While handling a few microservices is manageable in deployment, the difficulty arises when the number is increasing as it would not be clear which service runs where, the durations, and the status of the service. The provisioning infrastructure, network, and communication between many microservices becomes difficult.

 

CI/CD

From the CI/CD perspective, the dependency management of the services plays a significant issue. Since each service has its own service life cycle, having different versioning rules might make it complex as each service has to know which version of the other services it depends on for communication. Having independent database management causes multiple schema updates which are interrelated. Defining the minimum viable testing subset makes it difficult in the CI/CD aspect.

 

Monitoring and Performance

The performance testing of microservices is a challenging task. There can be releases of services with minimal changes and testing user experience through the UI results in multiple testing scenarios that will no longer work. When performing load testing, having the microservices in different technology stacks makes life more complicated. If fifty microservices are responsible for a particular transaction that fails, it is difficult to determine which microservice is with the fault when monitoring. It is also essential to know the resources usage of microservices and the number of messages it processed for future reference.

 

Message Tracing and Error Handling

Debugging is complex and challenging with microservices as logging is distributed. Inconsistent logging in multiple locations makes it difficult to find an error for the developers. They have to check the entire environment to find out a particular error.

 

Best Practices to face the challenges

Several best practices that need to be followed to face the challenges mentioned above are as follows:

  1. Choose a framework and a coding standard.
  2. Develop processes and guidelines within the company considering agile practices.
  3. Use cloud-native tools such as Docker and Kubernetes.
  4. Use inbuilt docker dashboards and monitoring tools or install other monitoring agents (For example, synthetic monitoring).
  5. Proper logging of messages for error tracing and handling.

 

Resources

  1. https://www.ibm.com/cloud/learn/microservices
  2. https://www.n-ix.com/microservices-vs-monolith-which-architecture-best-choice-your-business/
  3. https://www.smartwavesa.com/blog-articles/microservices-architecture-development-challenges/
  4. https://otomato.link/cicd-for-microservices-challenges-and-best-practices/
  5. https://www.neotys.com/blog/testing-monitoring-the-performance-of-microservices/
  6. https://www.codemotion.com/magazine/dev-hub/backend-dev/troubleshooting-debugging-microservices/