I am using AWS API gateway to invoke my aws lambda functions. They are REST web-services that will return response back to the caller. Some of the responses are more than 20 MB. Due to the nature of the response data (data is polylines that represents complex structures) I cannot use pagination here. AWS Lambda got the limitation of lambda response body cannot exceed 6MB size and due to this limitation some of my responses that are above 6MB are failing with 'body size is too long' message. I would like to know is there a way to increase the 6MB limitation of lambda responses?
Function configuration, deployment, and executionThey cannot be changed. The Lambda documentation, log messages, and console use the abbreviation MB (rather than MiB) to refer to 1024 KB. 128 MB to 10,240 MB, in 1-MB increments.
Lambda Payload Limit There is a hard limit of 6mb when it comes to AWS Lambda payload size. This means we cannot send more than 6mb of data to AWS Lambda in a single request.
AWS Lambda Payload Size Limit There is a 6 MB payload size limit for synchronous invocations and a 250 KB size limit for asynchronous invocations.
Thanks for the comments, I have implemented in the same way as mentioned in the comments
Uploaded the response to s3 bucket, and provided a redirect url to the caller. Here is the sample code that works. You may also enable CORS at s3 bucket level to make it work well. You may change to the correct region
public String uploadToS3(Set<MyClass> myclassSet, String bucketName) throws IOException {
Region region = Regions.getCurrentRegion();
if (region == null) {
region = Region.getRegion(Regions.US_EAST_1);
}
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withRegion(region.getName())
.withCredentials(DefaultAWSCredentialsProviderChain.getInstance())
.build();
ObjectMapper mapper = new ObjectMapper();
String jsonClass = mapper.writeValueAsString(myclassSet);
s3Client.putObject(bucketName, "random_key.json", jsonClass);
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, "random_key.json");
URL url = s3Client.generatePresignedUrl(req);
String redirectUrl = url.toString();
return redirectUrl;
}
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