Monoliths and Microservices
Before an organization delivers a product, the engineering team needs to decide on the most suitable application architecture. In most cases two distinct models are referenced: monoliths and microservices.
Regardless of the adopted structure, the main goal is to design an application that delivers value to customers and can be easily adjusted to accommodate new functionalities.
Each architecture encapsulates the three main tires of an application:
- UI (User Interface) or some times referred to as the client which handles HTTP requests from the users and returns a response
- Business logic - which contains the code that provides a service to the users
- Data layer - which implements access and storage of data objects
Monoliths
In a monolithic architecture, application tiers can be described as:
- part of the same unit
- developed in one programming language
- managed in a single repository
- sharing existing resources (e.g. CPU and memory)
- released using a single binary
A diagram refrencing the three tires using the Monoliths architecture.
Imagine a team developing a flight booking application using a monolithic approach. In this case, the UI is the website that the user interacts with. The business logic contains the code that provides the booking functionalities, such as search, booking, payment, and so on. These are written using one programming language (e.g. JavaScript) and stored in a single repository. The data layer contains functions that store and retrieve customer data. All of these components are managed as a unit, and the release is done using a single binary.
Microservices
In a microservice architecture, application tiers are managed independently, as different units. Each unit has the following characteristics:
- managed in a separate repository
- owns independently allocated resources (e.g. CPU and memory)
- well-defined API (Application Programming Interface) for connection to other units
- implemented using the programming language of choice for example in our example above the search could be implemented in javascript and the payments service is implemented using python
- released using its binary
A diagram refrencing the three tires using the Microservices architecture.
Now, let's refer back to a team developing a flight booking application but using a microservice approach this time round.
In this case, the UI remains the website that the user interacts with. However, the business logic is split into smaller, independent units, such as authentication, flight search, payments, confirmation, and many more. These units are stored in separate repositories and are written using the programming language of choice (e.g. JavaScript for the payment service and Python for the authentication service). To interact with other services, each unit exposes an API. Lastly, the data layer contains functions that store and retrieve customer and order data. As expected, each unit is released using its own binary.