Updated: Nov 15, 2021
API gateways make life easier for service developers and consumers. Here's what you need to know about the topic.
Microservices architectures continue to be a strong trend and offer many advantages for both developers and consumers.
API Gateway - Definition
API gateways are an essential result of the microservices trend. They simplify and stabilise the interfaces on the client side. In addition, an API gateway realises further advantages. These include, for example:
An API gateway is similar in its basic structure to the structural pattern of the façade, only on the network level. The objective, however, is the same - to simplify the interface and hide the complexity of the system:
API Gateway - Functions
The API Gateway provides for the decoupling of clients and services. It is the sole point of contact for incoming and outgoing traffic.
A microservices backend may contain many interacting services, which may have a heterogeneous structure in terms of URLs and protocols. An API gateway can provide a unified interface for clients to interact with - essentially a 'simplification proxy'.
However, an API gateway can also be more sophisticated, pulling together the necessary resources for a request and delivering them in the form of a single response. For example, a request for a user profile may include user details, recent messages and interests. The API gateway is able to request the required data accordingly and then output a response with all the information. However, to realise this capability, architecture-level orchestration is required, and there are also implications for other microservices components such as circuit breakers and service mesh.
Because an API gateway is able to transform protocols and URLs in the backend, it is also well suited for migrating services. In addition, an API Gateway can optimise the stability of the interfaces with which clients interact, while allowing the services themselves to evolve. Generally, the more complex the services and the higher the frequency of changes, the more valuable an API gateway is. Another advantage is that a gateway can be used to manage the topology within a microservices architecture more easily.
API Gateway - Monitoring and Security
Because of its role within the IT architecture, an API gateway is very well suited for monitoring, alerting and tracing. It can also be used to collect statistics for a wide-ranging analysis of traffic and usage:
There are many ways to link a logging service to an API gateway - for example, using Amazon Elasticsearch.
If the interface usage is based on a pay-per-use model, an API gateway can also be used to set rate limits and track charges. Tracking users and their API usage is much easier with a single point of contact.
However, this can also raise the need to harden IT systems. This then works in a similar way to a jump host in system administration: the services ensure that their communication with the API gateway is secured. This is a much simpler approach compared to multiple public-facing APIs.
API Gateway - Solutions
API gateway solutions fall into two categories:
Managed API gateways are offered by all major cloud providers, such as Microsoft, AWS and Google. If you want to set up your own API gateway, it is advisable to start with a framework - for example Spring Cloud or Nginx. (Infoworld)