What is monolithic architecture?
What are the benefits of monolithic architecture?
- Monolith means something which is composed all in one piece.
- The Monolithic application describes a single-tiered software application in which different components are combined into a single program from a single platform. The monolithic software is designed to be self-contained. The components of the program are interconnected and interdependent rather than loosely coupled as is the case with modular software programs.
- In a tightly-coupled architecture, each component and its associated components must be present in order for code to be executed or compiled.
- Also, if we need to update any program component we need to rewrite the whole application, whereas, in a modular application, any separate module e.g a microservice can be changed without affecting other parts of the program. Unlike monolithic architecture, the modules of modular architectures are relatively independent which in turn reduces the risk that a change made within one element will create unanticipated changes within other elements. Also, modular programs also lend themselves to iterative processes more readily than monolithic programs.
What are the benefits of monolithic architecture?
- Monolithic programs typically have better throughput than modular approaches.
- They can be easier to test and debug because with fewer elements there are fewer variables that come into play.
- Simple to deploy. We have to copy the packaged application to a server.
- Simple to scale horizontally by running multiple copies behind a load balancer.
- If the application is complex and large, it will be challenging to incorporate any new changes in it because all the modules are interdependent.
- Since all the components are combined into a single program, it increases the size of an application. This can slow down the start-up time.
- For any new update, we need to redeploy the entire application.
- If there is a bug (e.g memory leak) in one of the modules, it can potentially bring down the entire process. Also, since all instances of the application are identical, that bug might impact the availability of the entire application.
- Microservice architecture, or simply microservices, is an SDLC approach based on which large applications are built as a collection of small functional modules. These functional modules are independently deployable, scalable, target specific business goals, and communicate with each other over standard protocols.
- Each module supports a specific business goal and uses a simple, well-defined interface to communicate with other sets of services.
- Each microservice can also be implemented using different programming languages, and have its own database, which ensures loose coupling. Moreover, a service can use a type of database that is best suited to its needs.
- Microservices are smaller and faster to test.
- Microservice architecture gives developers the freedom to independently develop and deploy services.
- They enable the continuous delivery and deployment of large, complex applications.
- It enables you to organize the development effort around multiple teams. Each team is responsible for one or more single services. Each team can develop, deploy and scale its services independently of all of the other teams.
- Starts the web container more quickly, so the deployment is also faster.
- Code for different services can be written in different languages.
- Microservices eliminate any long-term commitment to a technology stack. When developing a new service you can pick a new technology stack. Similarly, when making major changes to an existing service you can rewrite it using a new technology stack.
- The application starts faster, which makes developers more productive, and speeds up deployments
- Improved fault isolation. e.g if there is a memory leak in one service then only that service is affected. The other services continue to handle requests. In comparison, one misbehaving component of a monolithic architecture can bring down the entire system.
- Developers need to deal with the additional complexity of creating a distributed system.
- Complete end-to-end testing is difficult. Due to distributed deployment, testing can become complicated and tedious as compared with Monolith applications.
- The Increasing number of services can result in information barriers.
- Inter-service communication mechanism is required.
- Implementing use cases that span multiple services without using distributed transactions is difficult and requires careful coordination between the teams.
- Increased memory consumption. The microservice architecture replaces N monolithic application instances with NxM service instances. If each service runs in its Container, which is usually necessary to isolate the instances, then there is the overhead of M times as many Containers.
- When the number of services increases, integration, and managing whole products can become complicated.
- Microservices Startup is fast, whereas service startup takes time in Monolithic Architecture.
- Microservices are loosely coupled architecture. Monolithic architecture is mostly tightly coupled.
- In Microservices changes done in a single data model do not affect other Microservices. In Monolithic Architecture, any changes in the data model affect the entire database.
- Microservices focus on products, not projects. Monolithic put emphasis on the whole project
- Multiple Service Instances per Host: Run single or multiple service instances of the application on single/multiple physical/virtual hosts.
- Service Instance per Host: Run a service instance per host.
- Service Instance per Container: Run each service instance in its respective container.
- Serverless Deployment: Package the service as a ZIP file and upload it to the Lambda function. The Lambda function is a stateless service that automatically runs enough micro-services to handle all requests.
The degree to which the elements inside a module belong together is said to be cohesion. Cohesion refers to the related logic between two or more services.
The measure of the strength of the dependencies between components is said to be coupling.
Coupling talks about how to change one thing needs a change in another, and cohesion talks about how we organize the code.
The entire concept of microservices is based on the ability to deploy and update services while keeping other services intact. Hence, loose coupling and high cohesion is the key to a microservice design.
The entire concept of microservices is based on the ability to deploy and update services while keeping other services intact. Hence, loose coupling and high cohesion is the key to a microservice design.
In short, the aim of low coupling between microservices is to promote independence and flexibility. Where aim for high cohesion within individual microservices to ensure that the functions within a microservice are closely related and focused on a specific business capability.
How does Microservice Architecture work?
A microservice architecture has the following components:
What are the challenges you face while working in Microservice architecture?
- Clients: Different users from various devices send requests.
- Identity Providers: Authenticates user or client identities and issues security tokens.
- API Gateway: Handles client requests.
- Static Content: Houses all the content of the system.
- Management: Balances services on nodes and identifies failures.
- Service Discovery: A guide to find the route of communication between microservices.
- Content Delivery Networks: A distributed network of proxy servers and their data centres.
- Remote Service: Enables the remote access information that resides on a network of IT devices.
- Monolithic Architecture is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.
- A Service-Oriented Architecture is a collection of services that communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity.
- Microservice Architecture is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.
Key Differences:
a). Granularity:
- Monolithic: Large, single unit.
- SOA: Services, which may be larger and more monolithic or fine-grained and independent.
- Microservices: Small, independent services.
b). Deployment:
- Monolithic: The entire application is deployed as a single unit.
- SOA: Services can be deployed independently.
- Microservices: Microservices are independently deployable.
c). Data Management:
- Monolithic: Typically has a single shared database.
- SOA: Each service may have its own database.
- Microservices: Each microservice manages its own database.
d). Scalability:
- Monolithic: Scaled by running multiple copies of the entire application.
- SOA: Services can be independently scaled.
- Microservices: Each microservice can be independently scaled.
e). Communication:
- Monolithic: Components communicate directly within the same process.
- SOA: Services communicate over a network using standardized protocols.
- Microservices: Microservices communicate via APIs, often over a network.
- Difficult to automate because there are a number of smaller components. For each component, we have to follow the stages of Build, Deploy, and, Monitor.
- Maintaining a large number of components together makes it difficult to deploy, maintain, monitor, and identify problems. It requires great notice-ability around all the components.
- Maintaining the configurations for the components across the various environments becomes tough sometimes.
- Difficult to find out each and every service for an error. It is essential to maintain centralized logging and dashboards to debug problems.
If you enjoy our content and want to support us, please consider donating via gpay, phonepay or paytm on +91 9920600280. Also, I’d appreciate if you’d buy me a coffee☕
Keep learning and growing!
-K Himaanshu Shuklaa..
No comments:
Post a Comment