Difference between Monolith and Microservices architectures .

Monica Iyabo
4 min readMar 11, 2023

--

Ima

I have always heard of microservices probably because it is the newer concept and there is a lot of hype around it yet as new software developer it i am more exposed monolithic architecture. Over this past year i have learnt a lot about the two architectures and in this article i will share with about them, when to consider one over the other.

What is a monolith?

A monolith is simply a single great stone often in the form of an obelisk or column according to Merriam-Webster.

A monolithic application is a single unified and indivisible unit, is the considered the traditional way of building applications. Usually when building a monolithic application the solution comprises a client-side user interface, a server side-application, and a database.

In this architecture, application tiers can be described as:

  • part of the same unit
  • code is managed in a single repository
  • resources (e.g. CPU and memory) are shared
  • code base is all made in one programming language
  • released using a single binary, deployed as a single unit.

Why should you choose

  • Simple to develop — the goal of current development tools and IDEs is to support the development of monolithic applications
  • Simple to deploy — you simply need to deploy the WAR file (or directory hierarchy) on the appropriate runtime
  • Simple to scale — you can scale the application by running multiple copies of the application behind a load balancer

What is microservices architecture

A microservice is simply a collection of small services which could be part of other small services or a bigger service and are independently deployable.

This architecture breaks down an application into a collection of smaller independent units or services, which are key business functionalities. The idea here is to split an application into smaller interconnected services.

Application tiers are managed independently, as different units. Each unit has the following characteristics:

  • code is managed in a separate repositories
  • resources (e.g. CPU and memory) are allocated to each unit independently
  • well-defined API (Application Programming Interface) for connection to other units
  • can be implemented using the programming language of choice depending on the engineer or functional requirements.
  • each unit is released using its own binary, and units are deployed independently.

Considerations to make

Sometimes an application can be designed using both, monolithic or microservice-based architectures. However, each architecture has a set of trade-offs, that need to be thoroughly examined before deciding on the final structure of the application.

Development Complexity

Development complexity is the effort needed to develop, deploy and manage an application.

  • Monoliths - one programming language; one repository; enables sequential development
  • Microservice - multiple programming languages; multiple repositories; enables concurrent development

Scalability

Scalability is how an application is the measure of a system’s ability to increase or decrease in performance and cost in response to changes in application and system processing demands.

  • Monoliths - require the replication of the entire stack; which makes it heavy and resource consumption high.
  • Microservice - requires replication of only units which are providing the services demanded, thus providing on-demand consumption of resources.

Time to Deploy

Time to deploy takes into consideration the time taken to ship features that is the time taken to build and deliver a feature.

  • Monoliths - there is one delivery pipeline that deploys the entire stack; more risk comes with each new deployment leading to a lower speed of delivery. A failure in one part causes the entire deployment to delay
  • Microservice - many delivery pipelines that deploy separate units; less risk with each deployment which leads to a higher feature development rate. A single failure may not affect other services

Flexibility

Flexibility implies the ability to adapt to new technologies and introduce new functionalities.

  • Monoliths - have low flexibility rate, since the entire application stack might need restructuring to incorporate new functionalities.
  • Microservice - have high rate, since changing an independent unit is simple and straightforward and in a break the changed unit will not affect the entire application.

Operational Cost

Operational cost represents the cost of necessary resources required to release a product.

  • Monoliths - have a low initial cost, since one code base and one pipeline should be managed. However, the cost increases exponentially when the application needs to operate at scale.
  • Microservice - high initial cost, since multiple repositories and pipelines require management. However, at scale, the cost remains proportional to the consumed resources at that point in time.

Reliability

Reliability looks at practices for an application to recover from failure and tools used to monitor an application.

  • Monoliths — in a failure scenario, the entire stack needs to be recovered. Also, the visibility into each functionality is low, since all the logs and metrics are aggregated together.
  • Microservice — in a failure scenario, only the failed unit needs to be recovered. Also, there is high visibility into the logs and metrics for each unit.

Conclusion

Having looked at both microservices and monoliths it is up to a business to choose the best way to go. Look at what your functional requirements are and what resources are available to you, how complex will your application be and use the above points as check list to decide what architecture to use.

References

This article is inspired by Udacity's Cloud Native Fundamentals Scholarship Program that I took some time back in 2021.

--

--