Microservices 101: An Introduction Into Microservice Architecture

Chanaka Palliyaguru
6 min readJun 1, 2021

With the rise of technology, we have been building systems and applications for many years now. Over those years we were able to see how different technologies, architectural patterns, programming languages, best practices and standards have emerged and how they were utilized to build solutions. Microservice architecture pattern is one such application development approach that has emerged over the years to solve the issues faced when developing applications utilizing the existing architectural patterns. This article discusses what microservice architecture is, characteristics of it, pros and cons, when it should be used and all the things a beginner or practitioner in Microservices should know.

What is Microservice Architecture?

Illustration of the Microservice architecture

Microservice architecture is a domain driven software development approach in which applications are made up of smaller single purpose independent services that communicate and interact with each other through light weight protocols like HTTP or through message broker services like RabbitMQ. Microservice architecture focuses on decomposing an application into services that carry out a specific business functionality or requirement. Each service should have a defined scope and its own business logic and also should be able to be developed and deployed independently. This approach to break the entire application into services makes it easier to change and update specific components as well as to scale the required components as per the need.

What is The Size Of A Microservice?

Newcomers into Microservices puts an extra focus on the size of the service due to the term “micro” in microservices and argues about what size the service should be. It is widely practiced that the service should be able to be developed and managed by a team of members not exceeding the Amazon’s notion of the Two Pizza Team(the whole team can be fed by two pizzas). It means that the team developing and managing the service should not exceed 12 members.

What are the Characteristics Of A Microservice Application?

According to famous author and software developer Martin Fowler, there is no proper definition to describe what microservice architecture is, so he lists out some common characteristics that outline how a microservice application should behave. Below mentions some of the characteristics that an application to be built following microservice architecture should adhere to.

Componentization via Services

Microservice architecture encourages that applications should be broken down into smaller services so that each of these services can be developed, deployed, updated/changed and redeployed independently without affecting the rest of the services. However, developing the application functionality in different services increases the overall application complexity as well as increases the development time since the developers need to spend extra time planning and implementing proper inter-service communications, fault handling and security mechanisms among services.

Organized around Business Capabilities

The microservice approach is usually organized around business functionalities and priorities. Unlike the monolithic approach where it focuses on technical boundaries and has different teams work on components like UIs, integrations, databases etc., microservice approach encourages to focus on business functionalities and use cross functional teams. Each team is given the responsibility to develop, deploy and manage a service/services which does a specific business functionality.

Simple Routing

Communication within microservices should happen similarly like a classic UNIX system where they receive requests, process them and provide a response accordingly without having to use products like the ESB(Enterprise Service Buses) where complex logics and mechanisms are utilized. Communications are done through REST API calls over HTTP or by light weight message brokers like RabbitMQ.

Decentralized Data Management

Data storage and manipulation should be decentralized from one single database to one database per service where each service will store and manipulate data related to it’s business functionality. It also promotes loose coupling and also makes it easier to scale.

Failure Resistant

Microservice architecture encourages applications should be designed to cope with failure. Microservices communicate with each other to provide functionality, therefore failure on one microservice should not affect the rest of the services and their business functionalities. Proper monitoring mechanisms and usage of design patterns like Circuit Breaker helps to prevent the risk of a failure.

Polyglot

Service development is independent from technology. Since services are independent from each other and inter-service communications happen through standard channels and protocols that do not rely on technology related bindings, development teams have the ability to choose the development stack that best fits to implement the service.

How Microservice Architecture Differs From Monolithic Architecture?

This section points out some of the ways on how an application developed following the microservice architectural approach differs from a traditional monolithic application.

  • In microservice approach, applications are built as a collection of different services that communicate with each other. Each service has a specific functionality, its own codebase/logic and can be built and deployed separately. In monolithic applications, all functionalities are built into one application using a single code base.
  • Microservices promote loose coupling where a failure or changes in one service does not affect the others. Monolithic applications on the other hand are tightly coupled where making changes is difficult and a failure in a module affects the entire application.
  • Unlike monolithic applications where data is centralized into a single database, data is federated in microservice applications. Having a different database per service increases scalability.
  • No dependencies between code bases in microservice applications therefore can use a different tech stack most suitable to implement the functionality in every service. In monolithic applications all functionalities and modules depend on each other.

Pros and Cons of Microservices

Advantages

  • Easy to understand and manage since microservices typically have small codebases and are focused on providing a specific functionality only.
  • Microservices allows to develop each service with different technologies giving developers the ability to use the best stack for each requirement. Due to this ability almost all client requirements could be fulfilled with ease.
  • Since microservices are self contained they can be independently deployed and scaled up and down according to requirements allowing to utilize resources efficiently. It also promotes faster deployments.
  • If a particular service becomes unavailable due to a failure, it does not affect the rest of the services, they remain intact continuously providing other services to end users.

Disadvantages

  • Higher complexity and development time since independent services need proper communication mechanisms and mechanisms to handle failures.
  • Debugging is difficult as the control might flow through different services in order to cater a user requirement. In such scenarios, pointing out when, where and why a problem occurred is complex.
  • Microservices can be less secure since there is communication between services through a network which could be vulnerable.
  • Deployment of microservices can be challenging as it needs coordination among other services and is not as straightforward as deploying a single WAR file.

When To Use Microservice Approach?

There are no die hard situations or business areas where it can be considered that microservice approach is the only best fit to develop the solution. But if the answers to the following questions are “YES” or at least to most of them, then microservice architecture can be considered as a good fit to develop the solution.

  • Do your development team members have expertise knowledge in microservice architecture?
  • Do you have enough resources to handle multiple services and instances?
  • Does the application need to be changed and deployed regularly?
  • Do you expect the application to receive large amounts of traffic?
  • Is priority given to the availability(uptime) of the application?
  • Do you expect the application to be deployed to the cloud?

Conclusion

It is clear now as to why the microservice approach is considered a good architectural pattern to build large scale solutions. Hope that the topics discussed in this article gave you a clear understanding on the what, why and when aspects of microservices. You can use this knowledge gained to dive deeper into microservices and explore more advanced topics.

References

--

--