Sunday, October 21, 2018

Microservices-1 Introduction (Monolithic vs Microservices Architecture)






Recently, there has been a lot of fuss about Microservices. There are a lot of discussions happening about Microservices in almost all the IT companies. Microservices architecture can be easily understood when we compare it with traditional Monolithic architecture.

Almost every enterprise application has a similar kind of layered architecture:
  1. Presentation: The user interface
  2. Business logic: The application’s internal business logic
  3. Database access: Almost all the application needs to access DB, either SQL or NoSQL.
  4. Application integration: Quite often application needs integration with other applications. This is usually achieved via webservice calls (SOAP or REST), or via messaging. 

Even though applications have quite clear logically modular architecture, but usually most of the application is packaged and deployed as a monolith. There’s actually some advantages of doing this.




Advantages of Monolithic Architecture:
  1. Development is quite simple
  2. Testing is very simple. Just launch the application and start end to end testing. We can also do test automation using Selenium without any difficulty.
  3. Deploying the monolithic application is straight forward, just copy the packaged application to the server.
  4. Scalability is simple. We just need to have new instance of the monolithic application and ask loadbalancer to distribute load to the new instance as well. But as the monolithic application grows in size scalability becomes a serious issue.

The Monolithic architecture had really worked successfully for many decades. In fact, many of the most successful and large applications initially developed and deployed as monolith. Many large scale enterprise applications of big companies still being deployed as monolith. But with the changing market, and with the emergence of new technologies there has been a paradigm shift in the way IT industries used to work. There are some serious issues with Monolithic architecture which most of the companies are trying to address these days.


Disadvantages of Monolithic Architecture:

  1. Flexibility: Monolithic architecture is not flexible. We can’t use different technologies. The technology stack is being decided at the start, and the same to be followed all throughout. Once the development gets mature sometimes it become difficult to even upgrade the agreed technology stack versions, forget about incrementally adopt a newer technology.
  2. Reliability: It's not reliable. If one feature goes down, the entire application might go down.
  3. Development speed: Development is really slow in Monolithic architecture. Difficult for new team members to understand and modify the code of large monolithic application. Code quality declines over the time. With the increasing code base the IDE too much overloaded and becomes slower. The larger the application the longer it takes to start up. All these factors have a huge impact on developer’s productivity. 
  4. Building complex applications: Difficult to build complex application, as limitation in technologies.
  5. Scalability: Monolithic applications are difficult to scale up once it gets larger. We can create new instances of the monolith application and ask loadbalancer to distribute traffic to the new instances as well. But Monolithic architecture can’t scale with an increasing load. Each copy of application instance will access all of the data, which makes caching less effective and increases memory consumption and I/O traffic. Also, different application components have different resource requirements - one might be CPU intensive while another might memory intensive. With a monolithic architecture we cannot scale each component independently.
  6. Continuous deployment:  Continuous deployment are extremely difficult. Large monolithic applications are actually obstacle to frequent deployments. In order to update one component we have to redeploy the entire application


Because of all the above drawbacks of Monolithic applications Microservice architecture is becoming more and more popular day by day. So what is Microservice based architecture?

Well in short, the Microservice architectural style is an approach to developing a single application as a suite of small services each running in its own process and communicating with lightweight mechanisms, usually RESTful webservice or via messaging. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There’s a bare minimum of centralized management of these services, which may be developed in different programming languages and use different data storage technologies. Microservices are small well-chosen independent deployable unit, which are cloud enabled.



Microservices architecture tackles all the drawbacks of Monolithic architecture:

  1.  Flexibility: Microservices architecture is quite flexible. Different microservices can be developed in different technologies. Since microservice is smaller, code base is quite less, so it’s not that difficult to upgrade the technology stack versions. Also, we can incrementally adopt a newer technology without much difficulty.
  2. Reliability: Microservices architecture can be very reliable. If one feature goes down, the entire application doesn’t go down. We can fix the issue in the corresponding microservice and immediately deploy it.
  3. Development speed: Development is pretty fast in Microservices architecture. Since the volume of code is quite less for a microservice it’s not difficult for new team members to understand and modify the code. They become productive right from the start. Code quality is maintained well. IDE is much faster. The microservice takes very less time to start up. All these factors considerably increases developer’s productivity. 
  4. Building complex applications: With Microservices architecture it's easy to build complex application. If the features of the application are analyzed properly, we can break it down into independent components which can be deployed independently. Then even the independent components can be further broken down into small independent tasks which can be deployed independently as a microservice. Deciding the boundaries of a microservice can quite challenging. It’s actually an evolutionary process. But once we decided on a microservice it’s easy to develop as there’s no limitation in technologies.
  5. Scalability: Scalability is a major advantage in Microservices architecture. Each microservice can be scaled individually. Since individual microservices are much smaller in size, caching becomes very effective.
  6. Continuous deployment: Continuous deployment becomes easier. In order to update one component we have to redeploy only that particular microservice.


As I mentioned earlier, Microservices architecture can be easily understood when we compare it with traditional Monolithic architecture. But prior to microservices there’s already similar kind of architecture available. Yes, I’m talking about SOA (Service Oriented Architecture). SOA has been there since last 2 decades. If you have already worked on SOA and are familiar with its concepts, it could be quite confusing to understand the differences between SOA and Microservices architecture. In fact, the two have more things in common than differences. In my next post on Microservices I will write about SOA, similarities among SOA and Microservices architecture, and of course the differences between them. 

Microservices-2 Introduction (SOA vs Microservices Architecture)

2 comments:


  1. Thanks for sharing useful information.. we have learned so much information from your blog.
    Microservices Online Training
    Microservices Training in Hyderabad

    ReplyDelete
  2. Jahid,

    I have scoured the internet for something that explains the evolution of application architecture from monolithic to microservices and talked to many experience people. You nailed it man! this is the best and simplest explanation which captures all the concepts and the differences in the architectures so well. In fact many I talk to would often skip the entire SOA and just talk only about how monolithic application gives way to microservices. Kudos for your effort and this blog!

    ReplyDelete