APIs & Integration Strategy
8
min of reading
January 3, 2018

Using Microservices Architecture as API Enablement Strategy

Rafael Rocha
Head of Solutions and Presales
A technologist degree in Information Technology from UNESP and a postgraduate degree in MBA Business Management from UNIMEP.
More about the author

Context

Currently, the architecture of Microservices became a hype within the software development segment. This architecture model is an approach that determines the deployment of applications in a range of services. The development team can adopt the most appropriate technologies to solve specific problems. The architecture of Microservices also increases the scalability by allowing the use of approaches such as auto-scaling and micro-container.APIs and microservices are closely related, since the standard is to use an API interface totally directed to RESTful. Nevertheless, we are still currently facing some issues when we need to integrate with legacy systems to outsource functionalities such as services, as most systems do not have protocols such as WebServices or RESTful interfaces; therefore, we are going to explore that topic.

The Problem and the Microservices approach

Most companies wish to expose APIs internally (within the corporation) and/or externally (to partners or clients), however, their systems or applications were not designed for that purpose. Most applications are based on the following architecture:

  • Monolithic web applications using a unique database. E.g.: Java (JSF) with Oracle database.
  • Product or platform, such as SAP ERP.
  • High level applications written in Cobol
  • Client-Server applications implemented in VB6 and SQL Server.

When we face that kind of scenario, the common solution is to build an adapter for exposing a standard protocol. That component should look like the diagram presented below:

The adapter is the main component for the solution, since it will allow the outsourcing of the service. To promote that standardization, some standards must be used:

  • Total compatibility with RESTful standard
  • Organization by business domains
  • Being easily scalable
  • Lightweight packages with a quick initialization.

To have an application with a simple and scalable integration model it is necessary to have an architecture style that meets all those requirements and the style of architecture that most closely resembles those features is the Microservices.Remember that this recommendation applies when your backend is not exposed with the HTTP protocol, because most API Gateways solutions will manage to easily route and transform messages for backend communication.Other scenarios in which the architecture of Microservices is highly recommended are:

  • Orchestration: in some cases, one should route and/or execute other services depending on some specific condition.
  • Composition: sometimes, it is necessary to execute more than one service to compose and return a response.
  • Transformation of Complex Messages: when it is necessary to use more complex algorithms in order to return a message to the consumer of the service.

Lastly, note that microservices need to be organized within the domains of your business. In this way, we can see that this style of architecture is an opportunity to break the monolithic of your business and provide better architecture, such as the design presented below:

Arquitetura Microserviços

This is a very interesting Microservices article.

Microservices Implementation Strategy

After deciding that the adapter implementation will be based on a Microservices architecture, some features are necessary:

  • Lightweight packages and low memory consumption
  • The initialization of the application must be fast to quickly create new instances of containers or servers.
  • Fast and simple development based on the Swagger specification
  • Security features like OAuth2

Some of the frameworks we suggest include:Java:

  • Spring boot
  • Spark Framework
  • Play Framework
  • Dropwizard
  • Apache Camel

JavaScript:

  • js

Another crucial feature when implementing APIs using Microservices is the ability to integrate with legacy systems. This type of feature requires a specific framework that implements the standards of business integration (EAI patterns); the recommendation in this case is to use the Java Apache Camel framework.

Microservices Implementation Strategy

After implementing the Microservices package and making sure it is ready, one should implement it so that it is available for use. The most recommended strategy is to use PaaS services (Platform as a service) to implement the Microservices packages. That is because this type of service offers some very interesting features like:

  • Use of containers
  • Orchestration of containers
  • Storage (file system and database)
  • Real-time monitoring
  • Logging and tracking

Two other important features are:

  • Being able to climb to support transportation
  • Offering APIs to automate the implementation process

The main PaaS offers in the market for an implementation strategy should be evaluated, including:

  1. Pivotal Cloud Foundry
  2. Red Hat OpenShift
  3. SalesForce Heroku

Other options that can be considered are Amazon Elastic Beanstalk and Google App Engine. Both are very interesting, as they have a native integration with Cloud and Infrastructure services and also offer infrastructure services as a service (IaaS).However, in our view, the best alternative for the implementation of microservices is that resulting from a complete integration with an APIs management platform and, in this case, the Sensedia API Suite offers a feature named BaaS (Backend as a Service) that uses the same PaaS service features and performs this integration.This feature allows you to perform the implementation and execute your microservices, directly exposing the APIs of your legacy systems.Technologies supported by BaaS are:

  • Java
  • js
  • Apache Camel

It is important to remember that if you can use this platform to run your microservices that are not only those that enable the integration with legacies, it could be your official microservice execution platform.

Microservices and API Management Platforms

After the Microservices are running correctly, the APIs that expose the Microservices must be well managed and some of the essential features for that, that most platforms of this type offer are:

  • Security and Resilience: necessary to protect your backend from people or applications not enabled to consume those APIs. When an API is opened for partners, its Microservices must be protected against peaks of transport, so that it is not out of service and, hence, it is necessary to have control of the traffic limit (Rate Limit and Spike Arrest) and size limit of the message body (Payload Size).
  • Access Control: API consumers must be under their control and, thus, one should use market standards such as OAuth 2.0 or JSON Web Tokens.
  • Monitoring and Tracking: one should manage to monitor all the types of requests made on their platform; in addition, one ought to have a powerful log mechanism to find the errors that occur in their API.

All the above capabilities are common in an API Gateway solution, but some other crucial features for the complete management of its APIs are:

  • Caching: it should be able to avoid unnecessary requests in one's API, offering a much better latency for one's requests, saving even the cost of one's backend infrastructure.
  • Analytics: the use of the API monitored in real time is very important, both to monitor consumption and to offer insights on how to sell, monetize and use API in the best way.

As mentioned above, some API Management Platforms offer full integration with the microservices execution platform. This type of functionality offers a total management of all the parts of the solution, not requiring a separate infrastructure. In that way, its architecture will be as shown in the figure below:

Arquitetura Microserviços e APIs

Conclusion

Using Microservices architecture allows the development of RESTful interfaces that will expose their legacy that natively does not have an HTTP interface, but the first challenge is to choose the correct tools for that implementation. There are many frameworks and languages ​​that can help in the implementation of microservices. The decision depends a lot on the scenario that is being faced, but some of the most used are mentioned in this article.After choosing your development kit, the next decision that must be made is to determine the implementation and execution platform. Once again, the decision depends a lot on the scenario that you are facing, but, in this case, the main objective is the exposure of RESTful APIs consistently meeting functional and non-functional requirements.Sensedia API Suite is an API management tool that manages to offer the functionality of Backend as Services (BaaS), which can replace the responsibilities of a PaaS in the implementation and execution of Microservices. Moreover, the tool offers all the key features for the ideal management of an API, such as API Gateway with Caching and Analytics.In short, the recommendation is to use one or more integrated platforms that manage to allow the total management of your Microservices and the APIs that will be exposed.

References

[1] Microservices – http://www.martinfowler.com/articles/microservices.html
[2] Apache Camel – http://camel.apache.org/
[3] PaaS Comparator – https://paasfinder.org/compare
[4] Twelve Factor App – https://12factor.net/
[5] Sensedia API Management Platform- http://sensedia.com/api-management-platform/
[6] API Gateway Pattern – https://www.nginx.com/blog/building-microservices-using-an-api-gateway/

subscribe to our newsletter with exclusive content.

Click and join the Sensedia News!

Click and join the Sensedia News!

Click and join the Sensedia News!

Thanks for reading!