Mono & Msa : Front 1. Introduction


Posted on Sun, Nov 6, 2022 architecture frontend

What is an Application Architecture

An application architecture is a roadmap with patterns and techniques used to design and build an application. It is one of the fundamental decisions to take before starting out with the development of an application.

Application architectures give guidelines on how front-end components connect, and how backend services interact with the front-end.

Application architecture can affect several behaviors of your application. It can affect implementation, maintenance, reusability of components, and level of collaboration.

Many application architectures exist today. Each has their unique approach, with corresponding benefits and drawbacks. We’ll talk more about these in the next section.

Choosing an Application Architecture

Choosing the right architecture for an application can be a very daunting task. Many architectures exist and they all have their benefits and drawbacks. Experiments can also be a great way to the most optimized architecture. Don’t worry much, because we’re getting there.

There are many types of application architectures, the most dominant today are based on the relationships between the services: monoliths (coupled) and microservices (decoupled). Let’s talk about them in detail!

Monolithic vs. Microservice Architecture

The Monolithic Architecture Introduction

A monolithic architecture is a self-contained and unified model of a software program. It is one of the earliest forms of system architecture that enjoyed enormous popularity in the 1990s and early 2000s.

The main reason behind monoliths' popularity during this period was simply because of the ease with which you could set and maintain a program written in such a pattern.

🔆

"The logic behind the monolith architecture is simple: bring several parts of an application together into a unified unit."

Failure or malfunctioning of one part of the application affects the entire setup. That was one of the main problems that the monolithic architecture faced as programs kept increasing in size.

The need for a more versatile and easy to maintain and scale architecture led to the development of the microservice architecture.

The Advantages of Monolithic Architecture

Though monolithic architecture may be difficult to scale and maintain, it still has some advantages that makes it an ideal architecture in the early project cycle.

Below are some advantages of monolithic architecture.

  1. Simpler to implement 🧩

    It’s quite easier to implement monolithic projects compared to microservice. Although monolithic apps can get very complex. So monolithic architecture simplicity depends on the type of project you’re building.

  2. Faster debugging 🕵️

    Debugging can be faster on monolithic architecture setup as all services are subsets of the monolithic tree.

    You can easily detect and correct errors in your monolithic application through end-to-end testing, as monolithic architecture arranges an app in a single indivisible unit.

  3. Easier to test ⚙️

    Monoliths are far simpler to test than microservice architectures. This is so because all you have to do is to run your application from a single code repository without worrying about any separate components.

    Monolithic applications are self-contained. Hence, all the units are tested together. Unlike in microservices, where services are deployed and accessed independently.

The Drawbacks of Monolithic Architecture

Many entities stopped using the monolithic architecture in development despite their advantages. Although there are scenarios where monoliths are crucial, large organizations are not using the monolithic pattern as growth is expected.

Below are some disadvantages of using monolithic architecture in development.

  1. Difficult to scale 👽

    It is very difficult to scale programs built with a monolithic pattern. This is simply because you have to scale all the sub-components together.

    This process is known as vertical scaling, which is very expensive and has limits. This is one of the problems that led to the development of other efficient architectures like the microservice approach.

  2. Single point of failure 🐥

    The failure of a single unit in a monolithic architecture leads to the breakdown of the entire system. This is one of the major problems with tightly coupled systems, monolithic architecture is not an exception.

  3. An increase in complexity 🕸️

    It can be very frustrating and complex to maintain monolithic apps as the codebase grows. With several developers working on one end of the project, changes made in one part of the program can alter other parts of it as they are all in unity.

  4. Barriers to technology adoption 😵

    Making a change to a unit in a monolithic architecture is very costly. Hence, developers are forced to stick with their local development tools. This can affect the overall system performance as technology advances every day and new features are being added.

    Refactoring data models and data sets can be quite time consuming in a monolithic set up. This problem can easily be solved by using micro services inside a monolithic architecture when organized and implemented the right way.

The Microservice Architecture

The setup in microservices is very different from that of a monolithic architecture. The microservice architecture separates each part of a program into different units.

An Application Programming Interface (API) serves as a medium for communication between the units. Each unit can be deployed, tested, scaled, and updated independently. Hence, the failure of one unit does not affect or lead to the entire breakdown of the system.

It's from this architecture that micro frontends emerged from.

The Benefits of Microservice Architecture

Many companies are switching to this architecture because of the ease with which applications are scaled and the flexibility it offers to the development team.

There are many reasons why microservice architecture is widely used nowadays. Below are some of them.

  1. Easy to scale 🗄️

    Applications built on a microservice architecture are scaled horizontally. This simply means that each unit can be increased independently as per need.

    This type of configuration is generally more cost-effective than vertical scaling, and there’s no limit to how much a unit or the entire application can be scaled.

    In microservices, the failure of one unit will not lead to the failure of the entire system. but performance may decrease. But its Business As Usual (BUA) approach keeps everything up and running.

  2. Increase in flexibility 🧬

    The microservice architecture promotes a high level of flexibility. A developer can work on different parts of an application without disrupting the system entirely.

    This is very important in an environment where roles are shared.

  3. Self-contained units 🎛️

    Remember that we mentioned applications being divided into units. These units are self-contained in the sense that they can be tested, deployed, and maintained independently.

    This is a great feature as you can easily work on different components without interfering with others.

  4. High dependability 🦾

    The freedom of changing only the affected unit in an application gives your application an undisputable level of reliability.

    With the use of circuit-breakers, load testing and balancing, and health check endpoints, micro services can stay operational for a very long time without compromise on efficiency.

Microservice Architecture's Drawbacks

Despite the surge in popularity of microservices over monoliths, there are some drawbacks that should be considered. Below are some of them.

  1. Difficult to implement 🕸️

    Microservice architecture has many advantages over monolithic architecture.

    When it comes to implementation, monoliths lead the way. It is quite difficult to design an application following microservice patterns.

    This is simply because you have to develop each part separately and then link them together. It’s a tedious task compared to the monolithic architecture.

    This problem can be solved easily with tools like docker. With docker, you can create services that run on separate containers. This tool can make implementation of microservice easier.

  2. It requires specialized skills. 🤯

    Microservices are learned by studying different methods of decoupling. Which may be difficult to source. This can lead to an exponential increase in development as a company may be forced to outsource to an expert. This can be very costly.

  3. Debugging challenges 🥺

    Debugging can be very frustrating at times in the microservice architecture. The main reason behind this is that each unit has its own logs. which, at times, can be very difficult to detect and correct.

Hexagonal and Microservice Architecture

Hexagonal architecture is an architectural concept developed by Alistair Cockburn. His main goal in formulating the concept was his attempt to prevent the unnecessary contamination of various layers of applications. He achieved that by separating user interfaces from the application’s business logic.

The hexagonal architecture is an alternative to the layered system architecture. It divides a system into several loosely coupled interchangeable components, such as the application core, the database, the user interface, test scripts, and interfaces with other systems.

The homogenous nature of hexagonal architecture with microservices made many people affirm that hexagonal architecture laid the foundation of microservices. They both share the same system design ideology, which promotes the design of loosely coupled applications.

Although hexagonal architecture played a role in the development of microservices, Peter Rodgers is recognized as the father of microservices as he introduced the term "Micro-Web-Services" during a presentation at the Web Services Edge conference in 2005.

You can read more about the hexagonal architecture to see more similarities between it and the microservice architecture. 📸

We'll look at some variations of the above-mentioned architectures, and some decoupling practices for coupled systems in the next section.

Scaling in Detail

💡

"Scaling is simply the ability to enhance the capacity of cloud systems so as to meet the ever increasing demands for bandwidths".

  1. Vertical scaling

    Vertical scaling is a way of enhancing systems specifications of existing infrastructures by adding more or replacing systems components like CPU, disks, etc with more powerful ones.

    Vertical scaling can be very difficult to achieve as the scaling can lead to several downtimes, and cost more money to implement.

  2. Horizontal scaling

    Horizontal scaling, which is also known as scaling out, is simply a way of enhancing a system's performance by adding new machines or computing nodes to improve data processing and storage capabilities.

    This type of configuration is very important in organizations that need zero-downtime and a cost effective solution of increasing the system's specification. Horizontal scaling is easier and quicker to achieve than vertical scaling in most cases.

    See you in the next segment! 🚀