Monolithic vs Microservices
Monolithic architecture is an application with a single code base that includes multiple services. These services communicate with external systems or consumers via different interfaces like Web services, HTML pages, or REST API
Microservices Architecture is an approach to developing a suite of small services working as a single application. The services are communicating through lightweight mechanisms, such as an HTTP resource API and each service is running independently in its own process
Monolithic: Brief
Build an application with a monolithic architecture application with a single code base that includes multiple services.
For example:
- a single Java WAR file.
- a single directory hierarchy or NodeJS code
Here, we have designed an e-commerce application with Monolithic Architecture.
We have added the big e-commerce box; those are the components of our e-commerce application: (Modules)
- Flights
- Hotels
- Trains
- Buses
- Cabs
As you can see, all modules of this traditional web application are single artifacts in the container.
This monolithic application has a massive codebase that includes all modules that are tightly coupled in a monolith codebase.
→ Simply like, All Program code of modules in one File (.jar).
Once the application becomes huge and the team Clients grow in size, this approach has a number of drawbacks that become increasingly significant
Drawbacks in Monolithic Architecture
- Difficult to understand code and Update new features
- Slower the Deployment
- The scaling of the Application is DIFFICULT.
- If any one of the modules (Like Cabs alone, ) gets Clients to hit in massive simultaneously then for scalability, the Entire App needs to be Deployed in the Container
- The entire Application needs to develop in the Same programming language for the Whole Application. As it cannot be possible or if any new module needs to create in another Programming language.
- Infrastructure development will be difficult
- Dependencies cause errors in the entire app if any changes are done in another module. (Fights — —> CoupounCode)
- The performance of one module will impact other
Monolithic architecture has many disadvantages, but for building a small application, monolithic architecture is one of the best architectures you can apply to your project.
Microservices
Microservices architecture will ease the Monolith drawbacks processes such as maintainability, reusability, scalability, Dependencies, availability, and automated deployment when it will be utilized, and these are considered the advantages of microservices architecture
So, Now Microservice is like,
Here, It is not a Monolith, as we have Independent services/Modules among them, Some of the Points in Microservices are given below.
Aspects of Microservices
- Small in size
- Single-responsibility
- Loosely coupled
- Explicitly published interfaces
- Lightweight
- Communicating via REST and HTTP
- Polyglot set of microservices (written in more than one language)
- Better performance in terms of throughput when it is used for a large number of requests
- A microservice application that will provide the backend capabilities by exposing the API
- The microservices gateway is the frontend of the whole system which will include all the APIs of every microservice application in the system
- Microservices governance is decentralized.
The main advantages of a microservices architecture are
- Microservices can rely on technology heterogeneity, which means each service in one system can use different technology than the other services to achieve the desired goals and performance
- If one component of the system fails then it does not affect the whole system.
- The process of scaling can be more accessible compared to monolithic application scaling because only the services that need actual scaling are scaled in the microservices architecture, contrary to a monolithic application requires to be scaled as a whole unit which may lead to higher hardware usage
- The ease of deployment is because with microservices each service can be deployed independently without affecting the performance of other services.
- Microservices architecture helps companies to align their architecture with their organizational structure, which will help them to minimize the number of people that are working on a specific codebase.
- Consequently, microservices enable organizational alignment. Further advantages are composability and optimizing for replaceability
- Each Module Service is independent of the programming language
- In this, the servers can communicate with other module servers.
- Distributed Software System.
- Fault tolerance.
- Communicating via REST and HTTP most widely popularly used, but there are other alternatives to REST, such as RPCs as not many are used currently.
- On the other hand, in the monolithic architecture, applications can be created of tens or hundreds of different services that are tightly coupled in a monolith codebase. Here, Each service can be maintained by different Dev teams and can build an efficient APP.
Here, we have designed an e-commerce application with Microservice Architecture.
We have added the big e-commerce box; those are the components of our e-commerce application: (Modules)
- Flights
- Hotels
- Trains
- Buses
- Cabs
Here, all modules are independent of each other in CodeBase, but they can communicate with each other. (Service to Service Communication)
For Example,
- If Flight Module is a more engaging module as a result simultaneous clients will be there, so we can accordingly scale out the containers in that Service/Module alone without creating an entire APP in the new System.
- Saves Time, Reliability, Scalability, and Space of the System.
- It can communicate with other modules to fetch the data.
- Flight Module alone has a Load balancer to manage the simultaneous clients coming to the APP only for that service.
Microservice Trend Over the period
In the mid-2000s, microservices began to appear, and a set of popular frameworks based on microservice architectures were developed, After being used at scale and enhanced for 10 years.
Companies benefited from Microservices
Halodoc: (CaseStudy)
Halodoc, a company, and app allow you to interact with a doctor right from your phone. As there are many people living in rural areas. they have restricted access to healthcare facilities
Halodoc is the No.1 health application in Indonesia
An app that makes it possible for a country of 264 million people,
with 50% internet penetration must have some serious technology behind it. And now I’m going to tell you how it works
As they started launching on new business lines it was obvious to a monolith will not cut it and they had to go the micro-service route as soon as possible.
All services were all these new interactions that your users changed to new microservices in your architecture.
- Each microservice has a couple of compute instances, backed by assistance, we use the RDS MySQL database.
- So, one group could be buying medicines online,
- the second group could be talking to a doctor online.
- And so on, It has 40 to 50 microservices in production
- Given that each of these microservices has their own databases
- The users’ data, As a user, could buy medicines or talk to a doctor, and these belong to different microservices .so used DynamoDB in AWS to save all of the user data.
- All of these services would use identity quite often having a low latency database, and being able to share that across all these microservices is a big benefit.
- Also, they use SNS(notification) to alert Dev teams between the microservices call they were having unnecessary tight coupling between our microservices.
- And more technologies are used behind. to maintain the synchronous
- They connect 22000+ doctors and 1500 pharmacies, across 50 cities in Southeast Asia.
Ref: AWS Architecture Blog
eBay
eBay, the world’s biggest online marketplace created a powerful platform for selling goods and services.
Enables trade on a local, national, and international basis with customized sites in markets around the globe, ensuring global e-commerce for an ever-growing online community
They started off with a monolithic Perl application, they had a monolithic C++ application that had up to 3.4 million lines of code in a single DLL.
- On the large-scale app, they move to a distributed and partitioned system in Java.
- eBay has quite a lot of Java but also functions on a polyglot set of microservices, that is, they are written in more than one language.
- The eBay system works with over 1000 microservices. For all types of Devices. (Web, Android, iOS)
Amazon
The Amazon.com website calls about 150 services to fetch the data that makes its webpage.
Netflix
Netflix is doing the same for its applications to be able to scale its services to over 80 million subscribers.
Many Tech Giants make ease of Operations with Microservices as a part of their Design.
FINAL
The Microservice architecture in DevOps practices together with the cloud environment is playing an important role in facilitating the implementation of microservices. We have also identified containerization as an effective method to overcome the hardware limitation besides speeding up the delivery process. Due to their smaller size, they shorten the delivery process and make scaling less challenging On the other hand, to use microservices, a highly automated system with an advanced monitoring capability is required
Microservice should be adopted where APPLICATION in monolithic reaches the point where it becomes hard to maintain or scale it.
The microservice architecture allows to use of different technologies for different services and allows to scale and maintain better, but all this comes with an overhead complexity and requires good expertise
Microservices’ governance is decentralized. and handling millions of requests by designing systems for huge availability, high scalability, and low latency.
THANK YOU !!