When and how you should use a microservices architecture

Contents

The Microservices Architecture It's getting a lot of attention lately, And this is no coincidence. There are some big companies like Netflix and Amazon who have explained how they are using a Microservices Architecture to be able to scale their services and ensure that they can provide them continuously and without interruption.

arquitectura20de20microservicios-1136876

A microservices architecture makes more sense compared to designing monolithic applications.

In monolithic architectural design, We created a huge, heavy application with all the modules tightly coupled within a single executable that is generally implemented on a web or application server. Despite this, This architectural design has some inconveniences that have allowed the use of the Microservices Architecture Become popular:

  • There are no easy and frequent updates.
  • Continuous Distribution Issues.
  • Difficult to manage team and project.
  • Costly performance and scalability.
  • Lack of technological diversity.
  • It's not easy to replace components.

What is a microservices architecture??

A microservices architecture style achieves a configuration where the application components are separate applications. These application-independent components communicate with each other via RMI (Remote Method Invocation), Restful Web Services or Push Messaging.

When designing systems in a microservices architecture, We need to identify the independent components. These components will be mini-apps, which will be developed separately. They will follow their own development and deployment cycle.

In a general configuration We can have scenarios where we need data from multiple components for a single request. Ideally, we'll have an API gateway or a front-end controller that aggregates the data from these components and returns it.

In addition, we must have communication between components. Components can communicate via REST API or messaging or RMI (Remote Method Invocation).

The characteristics of a microservices architecture-based application are as follows:

  • Service Enabled, Component-Independent Execution.
  • Independent execution of components around some business capabilities.
  • Product mindset instead of project.
  • Intelligent components that use simple communication channels such as the simple RESTish protocol or the lightweight message queue.
  • Decentralized Standards. Each standalone component can use its own unique standard for development and deployment.
  • Decentralized Data Management. Each individual component has its own data storage.
  • Automated Infrastructure Management. For the implementation of stand-alone components, We must rely on automated infrastructure management to reduce complexity.
  • Designing the application with possible failures in mind. There are several independent moving parts in the apps. In case the receiver doesn't get a response, must be managed correctly.
  • Evolutionary design to obtain the best feasible decomposition system, that can be replaced and upgraded without affecting your environment.

When to Use a Microservices Architecture

We should use a microservices architecture for any product or project with these two approaches:

  • Monolithic only or with a monolithic first approach. Regularly, When a monolithic application succeeds or needs help scaling and improving performance, We can opt for a microservices architecture in two ways:
    • Expand Well-Designed Modular Components of Monolithic Application.
    • Build the microservices application from scratch and dump the existing monolithic application into it.
  • A Microservices-First Approach. We should go for the first microservices approach when:
    • Modularity and decentralization are an important aspect from the beginning of any project.
    • We anticipate that the app will have a high volume of transactions or traffic.
    • We have a preference for long-term benefits over short-term ones.
    • We have the right set of people to design, Develop and implement applications quickly, especially during the initial stage.
    • We are committed to the use of state-of-the-art tools and technologies.

How to Use a Microservices Architecture

Unfortunately, Most of the available information about microservices architecture explains why they should be used, But not how.. Good to know that microservices could revolutionize design, the deployment and operation of applications. But, How exactly do you build a single microservice?? You need to understand the fundamental components of a microservice if you want the output to work properly and not end up looking like the same monolithic application with a fresh coat of paint.

These are the Five items a microservice will need before it can be used in a distributed application architecture:

  1. Functionality with proper scope. The first element of a microservice is to establish what it should do. One way to establish the appropriate scope is to divide services based on logical functionality. Another scoping approach is to reflect the structure of the development organization. A third approach is to minimize a service to the amount of code that the team could reintroduce in a two-week period.
  2. Prepare an API. Once we split an app into multiple co-op services, How should those services communicate with each other?? Regularly, this is done with calls to the REST web service API, even though other transport mechanisms can also be used. It's a good idea to avoid jumping into API coding right away. However, It's best to work on paper or whiteboard to establish what a specific service needs to expose in order to function properly.
  3. Traffic management. From a call service perspective, You should always follow up on your calls and be ready to end if the solution takes too long. From the perspective of the service called, the API design should include the ability to send a response indicating overload. Services must also be able to generate and delete new service instances as needed to accommodate variations in traffic load.
  4. Data download. Having the need for continuous operation is very different from what traditional applications need, that often stop working if the underlying infrastructure fails. To ensure that users can continue to work when an instance fails, User-specific data can be migrated out of service instances to a shared redundant storage system reachable from all service instances. Another approach to offloading storage is to insert a memory-based cache share between a given service and the storage associated with that service.
  5. Surveillance. The monitoring system of an application based on a microservices architecture must allow for the continuous change of resources, Be able to capture monitoring data in a central location and display information that reflects the changing nature of microservices applications.

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/es_ES/all.js#xfbml=1&status=0”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, 'facebook-jssdk'));

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.