What is a monolithic architecture?
A monolith service is a traditional approach to software development where the entire application is built as a single, self-contained unit.
What is meant by single, Self-Contained unit?
Presentation Layer:
This is the "face" of your application, interacting directly with the user. It can be a web interface, a mobile app, a desktop application, or any other user-facing element.
Technologies used in this layer depend on the chosen platform, but can involve HTML, CSS, JavaScript, React, Angular, etc.
Business Logic Layer:
This layer houses the core functionality of your application. It processes user input, performs calculations, makes decisions, and interacts with the data layer.
It's built with programming languages like Java, Python, Ruby, etc., and frameworks like Spring, Django, Rails, etc.
Data Layer:
- This layer manages all the application's data, including storing, retrieving, and manipulating it. It's typically a relational database (e.g., MySQL, PostgreSQL) or a NoSQL database (e.g., MongoDB, Cassandra).
Infrastructure Layer:
This layer handles the deployment and operation of the application. It includes servers, networks, operating systems, and any other supporting infrastructure.
Cloud platforms like AWS, Azure, or GCP are often used for scaling and management.
These components are all tightly coupled and interconnected within the same codebase. This means that a change in any one component can potentially impact the entire application.
Additional Elements:
API Layer: In some cases, monoliths may expose an API (Application Programming Interface) for integration with other systems.
Messaging Queue: For asynchronous communication between different parts of the application, a message queue system may be implemented.
What is a microservice architecture?
Microservice architecture is a distinctly different approach to building software compared to the traditional monolith style. Instead of one big, tightly coupled codebase, it decomposes an application into a collection of small, independent services. Each service owns a specific business capability and communicates with other services through well-defined APIs.
What is collection of small, independent services?
A microservice architecture application consists of several key components working together:
1. Microservices: The heart of the system, these are small, independent, and focused services that perform specific business capabilities. Each service owns its data, logic, and infrastructure, and communicates with other services through well-defined APIs.
2. APIs: These act as the communication channels between different microservices. They provide a standardized interface for services to send and receive data, ensuring loose coupling and clean boundaries.
3. API Gateway: This acts as a single entry point for all external requests to the application. It routes requests to the appropriate microservices based on the API call and handles any necessary pre-processing or post-processing.
4. Data Management: Each microservice may have its own dedicated database or utilize a shared centralized database depending on the specific needs and data consistency requirements.
5. Infrastructure: Microservices can be deployed and run on various platforms, including virtual machines, containers (e.g., Docker), and serverless platforms. This allows for flexible scaling and resource allocation.
6. Management and Monitoring: Managing and monitoring numerous independent services requires advanced tools and techniques. Automated deployment, configuration management, service discovery, and distributed tracing are crucial for maintaining a healthy and efficient microservices ecosystem.
7. Development and Operation: Microservices often require a shift in development and operational practices. Smaller teams focused on specific services, continuous integration and deployment (CI/CD) pipelines, and a decentralized approach to development and troubleshooting become essential.
Beyond these core components, depending on the specific application and its needs, the following elements may also be present:
Message Queue: Enables asynchronous communication between services, decoupling them further and improving performance.
Event Bus: Publishes and distributes events throughout the system, allowing services to react to changes without direct communication.
Cache: Improves performance by storing frequently accessed data locally within each service.
Remember, the specific composition of a microservices architecture application can vary depending on the individual needs and complexity of the system. However, understanding the core components and their interactions will give you a strong foundation for understanding and working with this powerful software architecture.