The use of the cloud does not bring any advantage in terms of scalability and flexibility if it is not accompanied by an application design that allows to exploit the features offered by cloud infrastructures. To achieve this goal it is necessary to abandon the monolithic approach in software development and choose solutions able to exploit all the potential of the cloud, e.g by selecting “Function as a Service” services like the AWS Lambda, the Google Cloud Functions and the Microsoft Azure Functions. 

Developing our web applications for cloud infrastructures we use  microservice architectures. The use of this architecture offers many advantages in terms of maintainability, flexibility, scalability and availability.

In this short article we will give an overview of the differences between a monolithic and a modular software solution and then, more specifically, we will illustrate what we mean by “microservices architectures” and what are their advantages.

 

Main objectives in software development

 

In addition to compliance with functional and security requirements and to absence of bugs, the main objectives in the development of an application are,  creating a software that can be easily maintained and modified allowing to meet future requirements without having to rethink the initial implementation. Moreover, we want to develop scalable and resilient applications with implications in the choices of software architectures and infrastructures.

For this reason, new architectural paradigms and design patterns are periodically proposed in order to achieve these goals. Obviously the continuous change of technologies and final application requirements leads to the birth of new approaches and new paradigms in software design and development.

 

A clear example is the well-known MVC (Model-View-Controller) design pattern in the case of frontend and backend interactions. This pattern is a fundamental pillar of any new framework that allows a clear separation between the data model, their processing (business logic) and their visualization. The separation of these elements allows development teams to modify the graphics of the application with little effort without upsetting the processes.

 

However, this approach does not solve some intrinsic problems of a monolithic architecture as it lacks a clear separation of responsibilities in the back-end, due to the various functionalities that this implements, and therefore only partially solves the problem, forcing, for example, the complete testing of the application at each software change thus slowing down the release of new versions.

 

Modular approach and its advantages

 

A new trend in recent years is the use of a modular approach in software development, isolating the several responsibilities created by the business logic, separating them into distinct modules and allowing each module to offer its own functionalities through a service that exposes a simple interface (API) that allows its reuse.

 

Some advantages of a modular approach are for example:

 – Separation of responsibilities: Each module is responsible for a certain set of operations. Its development is independent from other modules. It can be developed and tested independently from other modules and has its own life cycle.

 – Maintainability: The modules are smaller and easier to understand than the monolithic solution as the developer has to worry about the micro service tasks declared in the contract represented by its API. Any problem is confined to a specific module and can therefore be analyzed and corrected in a simpler and more time effective way.

 – Reuse: once a certain functionality has been encapsulated in a service, it can be reused not only within a specific application but also by other applications that need the same functionality (e.g. a calendar management module used by different applications or services) .

 

The microservices architecture is particularly suitable for development in the cloud environment, where it provides greater advantages. Depending on the specific functionality of the micro service, this can use the most suitable PaaS (Platform as a service) cloud solution (function-as-a-service, microapp, message based communication, etc.).

 

 

Moreover, depending on the business logic that the micro service will have to implement, it can choose the most suitable database, be it a classic relational database, a noSQL database or a file bucket.

 

An additional advantage is related to scalability. Let’s imagine that our application suddenly has to carry a greater load and that this load affects only a certain number of functionalities. In a monolithic approach or anyway in an approach where resources cannot be allocated independently to the features offered, more resources must be provided to the entire application with unnecessary increase in overall costs (vertical scaling). In a microservices approach, on the other hand, it will be enough to scale the specific micro service concerned in a timely manner and only when necessary (horizontal scaling). The micro service will in fact start only when invoked, will use cloud resources only for its lifetime, plus a start-up overhead, and will scale according to the particular request load.

 

For this purpose, cloud platforms have, with the various PaaS solutions, many tools to facilitate the prototyping of these services, offering tools for managing scaling, availability (load balancing, traffic control and necessary instances, etc.), configuration and off-the-shelf solutions for common problems such as authentication and integration between microservices (eg: messaging systems).

 

Issues to be considered when using microservices architecture

 

However, we must not think of microservices architecture as the solution to every problem. Greater flexibility and scalability are obviously obtained in exchange for greater complexity.

This complexity manifests itself mainly in the design phase of the micro service API and is mainly due to two aspects:

 – Reuse: in order to ensure the reuse of the service, the latter must be purged of unnecessary elements that are part of the monolithic application, making it a standalone service.

 – Management of error conditions – Maintenance / Monitoring: in an architecture composed of various microservices, it can be difficult to determine which service is causing the error. For this purpose, cloud platforms already offer tools that allow to mitigate this problem. However, it is important that the service API is defined in an exhaustive manner, declaring in its documentation: input validation rules, output format, any error conditions.

 

The Wondersys development team