Building a cloud-native API management architecture with CI/CD
Executive Summary
Moving from a centralized API management architecture to a decentralized one is essential for modern consumers and businesses. This article explores the following in detail:
- Traditional centralized architecture and its limitations
- Decentralized architecture and its key advantages
- How to handle Ingress gateway traffic routing
- Grouping of APIs for coming up with CI/CD flow
- Scaling and management of APIs
Introduction
Consumers play a key role in today’s businesses globally. Modern businesses take great efforts to become more innovative so that they can meet the expectations of increasingly technologically sophisticated consumers. With the rise of social media, consumers are more aware of their surroundings and the competition is not between businesses, but to meet customer needs. In this context, traditional centralized enterprise architectures no longer meet the expectations of both businesses and consumers. Let’s look at the typical API management story as an example.
Many API management solutions today look like the above diagram. There could be multiple service implementations and all of these are fronted from the centralized gateway. There is an API Manager control plane for access token generation, access token validation, traffic management, etc. If your API management platform has hundreds of APIs, then all of these APIs are deployed in this centralized API Gateway. If you scale the API Gateway due to the resource usage of a single API or high volume of traffic of a single API, you basically scale all of your APIs irrespective of API usage. This centralized API management architecture no longer meets the following requirements that arise due to different consumer needs:
- Different resource usage of the APIs
- Different security enforcement requirements of the APIs
- Need of dynamic routing of the API backends
- Message mediation and transformation
- API shaping based on different consumers such as mobile users, desktop users, etc.
- API response caching requirements
- Private vs public APIs
- API Gateway per department/unit
Decentralized API Management
This architecture pattern addresses the above requirements in a number of ways.
A decentralized approach has multiple API gateways, compared to a centralized API Gateway that had a single gateway with all the APIs. One API gateway can have one or more APIs based on different groupings. If you have an API that has a high volume of traffic, then you can have your API in a single API gateway. This helps the API to scale based on the traffic and this does not affect the other APIs. There can be cases where you have a set of APIs that come under certain grouping. For example, APIs that are related to an online shopping store can reside in a single API Gateway.
If you look at the traditional API Gateway that is used in centralized API management, it has some limitations such as startup time, resource usage, etc to be used in a decentralized API management solution. This is where we introduce the WSO2 API Microgateway which is a cloud native and developer centric API gateway. This is a lightweight version of API Gateway specifically designed for microservice architecture. The API Microgateway is designed to scale which has around one second of startup time and the memory footprint is very low. WSO2 API Microgateway is designed to work in locked-down and isolated environments, making it very easy to scale.
Why Decentralized API Management?
Modern application development practices mandate a more decentralized approach. Due to the limitations of monolithic architecture, businesses are now moving towards the microservices architecture (MSA). Independent modules are one of the advantages of the MSA. You can test, deploy, and run your modules separately. This improves productivity and gives the development team more autonomy to self serve. As the development team gets early feedback, this opens up room for new innovations and helps the team to bring new ideas to the market. The MSA philosophy also favors decentralization in all aspects of software design.
Decentralized API Management Architecture
This is a cloud native architecture based on containers where it runs on Kubernetes. The idea is to utilize the key features such as auto scaling, auto healing, workload management, etc. that container orchestration systems provide.
The data plane is considered as the most crucial plane as it contains the API Microgateways and microservices. In order to consume APIs, consumers access the Ingress gateway in Kubernetes. The Ingress gateway could be an Nginx or ALB in Amazon, etc. The Ingress gateway has relevant API Microgateway mappings so that it routes to the relevant API Microgateway based on the incoming request.
Apart from the data plane, you can have the control plane and management plane. The control plane contains the traffic manager which is for rate limiting purposes and the key manager for access token issuing and validation. The management plane contains the API Publisher for API designing and lifecycle management, API developer portal for API discovery, and API Analytics for API related business insights.
Ingress Gateway Traffic Routing
A decentralized API management architecture has multiple gateways that hold different APIs. One challenge we face is how to configure the Ingress gateway where a single endpoint that can route traffic to the respective gateway. This is not a challenge encountered in a centralized API management architecture. In many use cases, API consumers interact with a single endpoint for API invocations.
In Kubernetes, we can add an Ingress resource for each API Microgateway. In the Ingress resource we can define rules as follows:
...
spec:
rules:
- host: mgw.ingress.wso2.com
http:
paths:
- path: /review/v1.0
backend:
serviceName: review-api
servicePort: 9095
- path: /inventory/v1.0
backend:
serviceName: inventory-api
servicePort: 9095
...
In this case, we have one microgateway for review API and another one for inventory API. The API context of these APIs are /review/v1.0 and /inventory/v1.0. As you can see in the Ingress resource, when the context of the review API is matched, the request goes to the review API Microgateway service. Similarly, this happens for the inventory API requests as well. Basically we can automatically add these rules in Ingress along adding APIs to the system.



