All About Microservices and Monolithic Architecture

Mohammad Mahmudul Hasan
7 min readJun 10, 2021

Microservices Architecture

Microservices is an architectural design for building a distributed application as a collection of units that are :

  • Highly maintainable and testable
  • Loosely coupled
  • Independently deployable
  • Organized around business capabilities
  • Owned by a small team

These units carry out every application process as a separate service. So all the services have their own logic and the database as well as perform the specific functions.

Within a Microservices architecture, the entire functionality is split up into independently deployable modules which communicate with each other through defined methods called APIs (Application Programming Interfaces). Each service covers its own scope and can be updated, deployed, and scaled independently.

Microservices Architecture

Key Features of Microservices

  • Microservices are small, independent, and loosely coupled. A single small team of developers can write and maintain a service.
  • Each service is a separate codebase, which can be managed by a small development team.
  • Services can be deployed independently. A team can update an existing service without rebuilding and redeploying the entire application.
  • Services are responsible for persisting their own data or external state. This differs from the traditional model, where a separate data layer handles data persistence.
  • Services communicate with each other by using well-defined APIs. Internal implementation details of each service are hidden from other services.
  • Services don’t need to share the same technology stack, libraries, or frameworks.

Benefits of Microservices

  • It is easy to manage as it is separated in different small units.
  • If there’s any update in one of the Microservices, then we need to redeploy only that Microservice / Module.
  • Microservices are self-contained and hence, deployed independently. Their start-up and deployment time are relatively less.
  • It is very easy for a new developer to on-board the project as he needs to understand only a particular Microservice providing the functionality he will be working on and not the whole system.
  • Microservices architecture supports horizontal scaling. If a particular Microservice is facing a large load because of the users using that functionality in excess then we can scale out that Microservice only.
  • Each Microservice can use different technology based on the business requirements.
  • If a particular Microservice goes down due to some bug, then it doesn’t affect other Microservices and the whole system remains intact, continues providing other functionalities to the users.

Drawbacks of Microservices

  • Being a distributed system, it is much more complex than the Monolothic applications. Its complexity increases with the increase in number of Microservices.
  • Skilled developers are required to work with Microservices architecture which can identify the Microservices and manage their inter-communications.
  • Independent deployment of Microservices is complicated.
  • Microservices are costly in terms of network usage as they need to interact with each other and all these remote calls results into network latency.
  • Microservices are less secure relative to monolithic applications due to the inter-services communication over the network.
  • Debugging is difficult as the control flows over many Microservices and to point out why and where exactly the error occurred is a difficult task.

Monolithic Architecture

The monolithic architecture is considered to be a traditional way of building applications.

Monolithic Architecture is the concept of connecting all components of the application to each other. The components are interdependent. One goes wrong and affects the function of the others and eventually the end product.

A monolithic application is built as a single and indivisible unit. It is unified and all the functions are managed and served in one place. Every Monolithic Architecture comes in three parts:

  • Client-side user interface
  • Server-side application
  • Database

A single code base is used to bring together back-end, front-end as well as background tasks. If anything needs to be changed, the entire stack has to be developed and deployed.

Monolithic Architecture

Benefits of Monolithic Applications

  • Simple to develop relative to Microservices where skilled developers are required in order to identify and develop the services.
  • Easier to deploy as only a single file is deployed.
  • Relatively easier and simple to develop in comparison to Microservices architecture.
  • The problems of network latency and security are relatively less in comparison to Microservices architecture.

Drawbacks of Monolithic Applications

  • It becomes too large in size with time and hence, difficult to manage.
  • We need to redeploy the whole application even for a small change.
  • As the size of the application increases, its start-up and deployment time also increases.
  • For any new developer joining the project, it is very difficult to understand the logic of large Monolithic application even if his responsibility is related to a single functionality.
  • Even if a single part of the application is facing a large load/traffic, we need to deploy the instances of the whole application in multiple servers. It is very inefficient and takes up more resources unnecessarily. Hence, horizontal scaling is not feasible in monolithic applications.
  • It is very difficult to adopt any new technology which is well suited for a particular functionality as it affects the whole application, both in terms of time and cost.
  • It is not very reliable as a single bug in any module can bring down the whole Monolithic application.

Microservices vs. Monolithic Architecture

In Monolithic applications, all the software components are tightly coupled and deployed as a single instance.

Monoliths contain all the functions in one structure; all the processes interact with the same server and are ultimately run on the same machine.

A microservices architecture can be developed, deployed, and maintained independently. Each of these services is responsible for discrete task and can communicate with other services through simple APIs to solve a larger complex business problem.

A microservices architecture consists of a collection of small, autonomous services. Each service is self-contained and should implement a single business capability.

Monolithic vs. Microservices Architecture
Monolithic vs. Microservices

Rules for Using Microservices

There is no actual official definition of what a Microservice is and is not; however, the following rules generally apply to commonly used Microservices:

  • A small unit of a backend infrastructure
  • Operating as independently as possible (meaning, no or little communication with other Microservices)
  • Performing a service (such as processing data or offering an API)
  • Offering as little functionality as reasonable
  • Operates with its own database

How to Decide Suitable Architecture

Generally, Monolithic Architectures are the right choice for small, simple app development. It’s also worth considering that a switch to Microservices won’t do any favors for a team that doesn’t have enough experience working with distributed architectures.

Alternatively, a Microservices architecture is a good choice when you’re developing for complex systems, especially if you have developers familiar with Microservices and motivated to make the switch.

So when it comes down to the Monolithic vs. Microservices debate, keep these four basic things in mind

  • Does your team have Microservices expertise?
  • Do you have the right infrastructure for distributed apps?
  • Have you evaluated the business risks involved?
  • Are your application boundaries clearly defined?

Use Cases of Microservices

Microservices are widely adopted across multiple tech giants. The implementation of microservices varies from a case-to-case basis. But some of the significant applications which run on microservices and are used on a day-to-day basis include:

Use cases of Microservices

Uber Old Architecture (Monolithic)

There was a REST API that connected the drivers to the passengers. Three different adapters were used within the APIs for billing, payments, emails, and messages. MySQL database was used to store all the data. So, all the functionalities of the application were encapsulated in a single framework.

Uber Old Architecture

Uber New Architecture (Microservices)

  • Introduce API Gateway to connect all the drivers to the passengers. The API Gateway internally connects all the Microservices such as Passenger Management, Driver Management, Trip management, etc., through REST API calls.
  • Each microservice performs a singular functionality and has separate deployable binaries.
  • Since all Microservices are loosely coupled, their interdependency is greatly reduced.
Uber New Architecture

Closing Thoughts

Adopting Microservices is a difficult approach. Not all architecture is the same. Similarly, not all applications are the same. Incremental adoption of Microservices, associated technologies, and practices is the key. Microservices are more beneficial for complex and evolving applications. However, without proper expertise in these technologies, the adoption of Microservice will be a colossal task.

e.g. Netflix takes 2 years 2 finish this conversion from Monolithic to Microservice (2009–2011)

--

--

Mohammad Mahmudul Hasan

A learner, constantly striving to learn new technologies and look the ways to be better in this rapidly changing industry.