I am running aws lambda which will fetch data from maria DB and return the fetched rows as a JSON object. A total number of item in JSON array is 64K.
I am getting this error:
{ "error": "body size is too long" }
Is there a way I can send all 64K rows by making any configuration change to lambda?
To troubleshoot Lambda code errors You can use CloudWatch to view all logs generated by your function's code and identify potential issues. For more information, see Accessing Amazon CloudWatch Logs for AWS Lambda.
Our API Gateway's Lambda Error Regex runs a check when throwing an exception in Lambda Function. It does not run on a regular response. Our Lambda Function packs the exception into an object called errorMessage by herself.
Make sure that you also set up the corresponding error code ( 400 ) on the method response. Otherwise, API Gateway throws an invalid configuration error response at runtime. At runtime, API Gateway matches the Lambda error's errorMessage against the pattern of the regular expression on the selectionPattern property.
You cannot send the 64K rows (Which goes beyond 6MB body payload size limit) making configuration changes to Lambda. Few alternative options are.
Note: Based on the purpose of queried data, its size & etc. different mechanisms can be used, efficiently using other AWS services.
This error indicates that your response exceeds the maximum (6 MB), which is maximum data size AWS Lambda can respond.
http://docs.aws.amazon.com/lambda/latest/dg/limits.html
It seems that you're hitting the hard limit of a maximum 6 MB response size. As it's a hard limit there's unfortunately no way to increase this.
You'll need to set up your lambda to be able to send at most 6MB and paginate through the rows you need to retrieve in different invocations until you've fetched all 64K.
Sources: https://docs.aws.amazon.com/lambda/latest/dg/limits.html#limits-list https://forums.aws.amazon.com/thread.jspa?threadID=230229
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With