In Monolith Application, components are tightly coupled and developed, deployed and managed as a single entity.
For example, as you see above diagram, all the components user interface, Caching, Service, Logging etc., are tightly coupled.
a. Since Monolith application holds all the components tightly, to run this application we require powerful servers.
b. Even though you are doing changes in one of the components, you need to redeploy the entire application.
c. In-case of high load, you need to scale the system Vertically or horizontally. You can scale the server Vertically by adding some more CPU cores and additional memory.
Vertical Scaling
Adding more memory and cpu cores to the same server.
Vertical Scaling has its own upper limits and not a cost-effective solution.
Horizontal Scaling
Adding multiple servers and running multiple instances of the application on different servers.
Even though horizontal Scaling is an ideal solution, all the components of monolith application may not scale horizontally because of design/technical limitations.
a. Since all the components are tightly coupled, if you develop all the components in some ‘X’ Programming language, new features also must develop in ‘X’ Programming language.
Microservice Architecture
In Microservice Architecture, Application is modularized into multiple tiny services called microservices. Each microservice is loosely coupled. Each microservice can communicate with other microservice using some standard like REST.
Since these microservices are loosely coupled
a. we can scale the services that are required and we can develop the services in the preferred language.
b. We can deploy a microservice without redeploying other microservices
c. We can scale microservices independently.
As you see above image, Services are written in different languages and scaled according to the load. Below table summarizes the same.
Service | Number Of Instances | Implemented language or framework |
UI Component | 1 | Nodejs |
Logging Component | 1 | Go |
Caching Layer | 2 | Java |
Messaging Component | 1 | Rust |
Service Component | 2 | Java |
Data Access Component | 2 | Java |
Drawbacks of Microservices
Even though Microservices has a number of advantages over Monolith applications, it has downsides also. Suppose take an example, where a complex system is divided into hundreds of microservices,
a. Deploying and managing these services is not easy.
b. We need to establish communication between these microservices properly.
c. Scaling the microservice on demand should be taken care of.
d. When a microservice is down, another instance of microservice should spin up to make the service available.
e. Managing the secrets among these services should be handled securely.
f. Microservices can run in different environments, how to handle them?
g. How to load balance this microservice?
h. Redeploying the previous version of microservice in-case of any failure or bugs in current deployment.
All the above problems will be addressed using Kubernetes.
No comments:
Post a Comment