wso2 API retry mechanism in throttling - wso2

I'm newbie on WSO2 platform.
I wanted to know how messages are stored and replayed when we exceed the quota. Regards.

how messages are stored and replayed when we exceed the quota.
The messages are not stored and not resent by api gateway itself. If quota is exceeded, the gateway returns a fault (exception with an error code 900800, here I may be mistaken).
It is task of the client to retry / resend the message

Related

How to reset Quota for API once exceeded in WSO2 APIM

How I can reset the quota if API access limited?
Suppose we have API subscribe for 1200 request count for three month plan now quota is exceed and we are looking for increase quota for same API and Plan so how to do that without creating new application, or subscription plan in WSO2 APIM
You can reset a subscription policy via WSO2 APIM's Admin Portal.
Go to Subscription Policies under Rate Limiting Policies menu.
Click on the edit button in front of the custom subscription policy that you have created.
Modify the quota limits as you wish.
Click on save button.
Now you can access the API with the new changes.
Note that you can observe the following log in carbon logs if the policy is deployed correctly:
INFO - EventProcessorDeployer Execution plan is deployed successfully and in active state : <policy_name>
AFAIK you can't extend or reset a throttle decision in the gateway. When an API is throttled out, the Traffic manager sends an event to the gateway with the throttle decision for the throttle key and when this decision will expire. A sample event is mentioned below.
{"event":{"payloadData"{"throttleKey":"1:/pizzashack/1.0.0:1.0.0:5for5mins","isThrottled":true,"expiryTimeStamp":1674491400000}}}
Gateway will update it's throttle data holder with this information.
When gateway receives request from the same application, it will check this data holder, see whether expiry time stamp is exceeded, and throttle out.
This data holder entry will persists in memory until you restart the gateway or expiry time exceeds. Therefore even if you update the throttling tier, if the API is already throttled, you can't reset or extend the quota.
Only option would be upgrading the subscription tier to a higher one. Thottle decision is based on the policy and a different policy will act as an extension.

AWS API Gateway will I be charged for the request excess the throttling limit?

For those requests excess the limit and get the response: 429 too many requests, will those requests still charge me?
In this question,t he throttling limit is the limit from the API gateway itself, no other limit.
It depends.
If you reached the limit for your usage plan and the API Gateway throttles you, there would be no additional costs. Although, this kind of throttling may not be as accurate as you would expect, see this question: AWS API Gateway Throttling not working as expected.
If your backend integration throws a 429 (for example, you reached some kind of Lambda limit), than your request will be charged on the API Gateway.

Lambda timeout after 29s, unable to find request ID in CloudWatch logs

I'm new to AWS and Node so I really appreciate everyone's suggestion on this one. Recently in my system, something strange happened. Sometimes (~20 times/ month), a lambda request got timeout. It's just a simple request in middleware for authentication (I'm using node.JS serverless). The issues is I cannot trace this request from API gateway. Sorry I'm suck at explaining things so I'm gonna put it like this:
My system's flow: CloudFront -> API Gateway -> Lambda -> RDS
Normally if I want to trace a request:
I get the requestID from Lambda's Log
And search it in the API Gateway's Log:
But for these Timeout request:
I cannot find anything at all in API Gateway's Log:
Like it appeared out of nowhere... Please help and thanks for the suggestion.
You may already be aware but API Gateway has a hard max timeout limit of 29 seconds and stops waiting for the integration to respond after that time.
The Request ID that you are pulling from the lambda logs is the lambda request ID. This is a bit of speculation but I'm guessing since the Lambda took longer than 29 seconds and never returned to API Gateway since API Gateway timed out and stopped waiting, the API Gateway never received a response from the Lambda function to know what the lambda request ID is.
There still should be some API Gateway logs for this invocation but it won't contain any of the normal integration response log lines because it never received a response from the lambda integration.
Perhaps try searching for 504 in the API Gateway logs since this is the response code when the gateway times out.
Or as AADProgramming recommends, the X Ray service was designed to help users track requests across many services so enabling that would be helpful here.

AWS MQTT broker scaling issues

I am using AWS IoT in my cloud application.
I have created IoT rules and lambda functions to process the MQTT publish messages.
When the MQTT Client publishes the message to a topic, a rule is triggered and a lambda function is executed.
While carrying out the load testing, I found that, after some time, MQTT broker doesn’t process the messages.
On the AWS IoT ( monitor ) console, I can see the number of successful connections reaching to 400.
My MQTT clients are opening around 50 connections, publishing the message and waiting for async response on another topic for 60 seconds.
After receiving the response or 60 seconds timeout, these connections are closed.
Then next set of 50 connection requests are made to AWS MQTT broker.
The client is developed using AWSIoTPythonSDK.
I don’t see any errors in the IOT console as well as in the Lambda monitoring console.
Also I don’t see any message or log, which says the request are throttled.
I have raised a request to increase the limit for number Connect Requests Per Second to 1000.
Is there any way to find out, if the MQTT broker is throttling the request or if there are any other errors?
Following url is about aws iot limits.
https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_iot
Did you turn on aws iot log(debug level or info level)? And Can you see connection logs in cloudWatch?

Is there a way to track calls throttled by API Gateway?

I've been using CloudWatch to track metrics against API Gateway and Lambda, and it shows throttled calls for Lambda, but is there any way to see the number of calls that are throttled earlier by API Gateway?
Not yet, but we are planning on addressing this in the near future. Can't provide an ETA. But it would be similar to Lambda in that there will be a metric counter for throttled requests.
You could setup CloudWatch alerts with SNS notifications to receive info about throttled request. Another way could be tracking the throttled HTTP 429 status on the client.