APIM260 - F3.1 - API - Gateway
APIM260 - F3.1 - API - Gateway
APIM260 - F3.1 - API - Gateway
0
Fundamentals
API Gateway
WSO2 Training
1
API Gateway
What is an API
Gateway?
The API Gateway is a runtime, backend component (an API proxy) developed using
WSO2 ESB. The API Gateway secures, protects, manages, and scales API calls. It
intercepts API requests, applies policies such as throttling and security using handlers
and manages API statistics. Upon validation of a policy, the Gateway passes Web
service calls to the actual backend. If the service call is a token request, the Gateway
passes it directly to the Key Manager.
When the API Manager is running, you can access the Gateway using the URL
https://localhost:9443/carbon. You integrate a monitoring and statistics component to
the API Manager without any additional configuration effort. This monitoring
component integrates with WSO2 Data Analytics Server, which can be deployed
separately to analyze events. For more information, see Working with Statistics.
Although the API Gateway contains ESB features, it is recommended not to use it for
ESB-specific tasks. Use it only for Gateway functionality related to API invocations.
For example, if you want to call external services like SAP, use a separate ESB cluster
for that.
API Gateway Processing Flow
API Gateway
Access Apply QoS Custom
Validate Token Publish Statistics
Token Policy Extensions
Validate Token
When a request comes to the API Gateway, it extracts the access token and validates
it against the key management server and then applies the QoS policy and then the
custom extensions that are defined are applied. If BAM/DAS is configured, statistics
will be published.
User Roles of API Gateway
API Invoker
Caching
Response Resource
Cache Cache
Key Manager
Cache
When an API call hits the API Gateway, the Gateway carries out security checks to
verify if the token is valid. During these verifications, the API Gateway extracts
parameters such as access token, API and API version that are passed on to it. Since
the entire load of traffic to APIs goes through the API Gateway, this verification
process needs to be fast and efficient in order to prevent overhead and delays. The
API Manager uses caching for this purpose, where the validation information is
cached with the token, API name and version, and the cache is stored in either the
API Gateway or the key manager server.
Cache
When caching is enabled at the Gateway and a request hits the Gateway, it first
populates the cache entry for a given token. If a cache entry does not exist in cache, it
calls the key manager server. This process is carried out using Web service calls.
Once the key manager server returns the validation information, it gets stored in the
Gateway. Because the API Gateway issues a Web service call to the key manager
server only if it does not have a cache entry, this method reduces the number of Web
service calls to the key manager server. Therefore, it is faster than the alternative
method.
Validation Information Caching
Cache
When caching is enabled at the Gateway and a request hits the Gateway, it first
populates the cache entry for a given token. If a cache entry does not exist in cache, it
calls the key manager server. This process is carried out using Web service calls.
Once the key manager server returns the validation information, it gets stored in the
Gateway. Because the API Gateway issues a Web service call to the key manager
server only if it does not have a cache entry, this method reduces the number of Web
service calls to the key manager server. Therefore, it is faster than the alternative
method.
Response Caching
The API Manager uses WSO2 ESB's cache mediator to cache response messages per
each API. Caching improves performance, because the backend server does not have
to process the same data for a request multiple times. To offset the risk of stale data
in the cache, you set an appropriate timeout period.
You can enable response caching when creating a new API or editing an existing one
using the API Publisher UI. Go to the API Publisher and click the Add API menu (to
create a new API) or the Edit link associated with an existing API. Then, navigate to
the Manage tab where you find the response caching section. You can set it to
Enabled and give a timeout value. This enables the default response caching settings.
THANK YOU
wso2.com