Learnitweb

Monolithic architecture

1. Introduction

This is the first article of Microservices with Spring series. In this article, we’ll discuss the monolithic architecture and its drawbacks which lead to the popularity of microservices. Not every architecture is bad and have few advantages. We’ll discuss advantages and disadvantages of monolithic architecture as well.

2. Monolithic architecture

monolithic architecture

In the monolithic architecture, there is one code base and usually built into a single war file. So you can say that a monolithic application is a one single unit.

3. Benefits of monolithic architecture

  • Simple to develop – A monolithic application is a single application. Almost all existing IDEs are designed to develop monolithic single application.
  • Easy to change – It is easy to change the code and it is only one application where you have to do the change.
  • Simple to test – A monolithic application is straightforward to test. A developer can write end to end test for the application.
  • Simple to deploy – A monolithic application is commonly a war file which is easy to deploy.
  • Easy to scale – It is simple to scale a monolithic application by scaling it to run on multiple instances.
  • Better performance – This is due to no network latency.
  • Fewer cross cutting concerns

4. Monolithic hell

In a monolithic application, there is a single code base. When new features are introduced to the application, the code base grows larger. As a result, the management overhead increases. There is a time when features keep adding to the application and the application outgrows the monolithic architecture. You can say that such application is in monolithic hell.

Another problem with a monolithic application is that it is too big and complex for a developer to fully understand. Developers become hesitant of changing the application which they find bit outdated. Any change may impact other parts of the application. Adding new features to the application becomes time consuming and complex. Each new change adds to the complexity of the application. Such application over the time become huge, complex and incomprehensible.

5. Development in monolithic application is slow

When the code base is huge, IDEs are usually slow to build and run the application. Building and start up of the application takes time. This reduces the productivity of the developer.

Another problem with the single code base is that the developers are committing to the same code base due to which the build is frequently in the unreliable state. To solve this issue. If you use the feature branch approach, then after the development is over, the lengthy and painful merge process begins. In the end the developers are working on the stabilization of the code base.

In terms of testing, since it is difficult to understand the entire code base, a developer is not aware of the impact of code change. It is very difficult for a developer and tester to test the entire application. Some part of the application is manually tested whereas some other parts are testing using automated test cases. It usually takes few days to finish the test cycle. And if some issue is found then this cycle repeats.  

The lack of testability of the monolithic application results in production bugs. A monolithic application lacks fault-isolation. An error in one module can impact other modules because all modules are running in the same process. So a memory leak in one module can crash the other instances of the application.

6. Difficult to upgrade technology stack

There is so much code coupled together in a single application which makes it very difficult to update the application. The monolithic architecture makes it difficult to adopt new frameworks and languages. It is very complex and expensive to rewrite and upgrade the entire application. Consequently, developers are stuck with the technology choices made at the start of the project.

7. Conclusion

The solution to all these problems is microservices. If you are building a large, complex application, you should consider using the microservice architecture.

In the upcoming articles, we’ll discuss SOA architecture and then the microservices.