0

I have a function that runs successfully (within 15 mins) when it is run in SAM CLI, but when I run the same code in AWS cloud, it times out. I have the same configuration for both the cases. So,

  1. What is the difference when a function code is run in SAM vs AWS cloud.
  2. How can I make sure the code that ran without timeout in SAM does not time out when run in AWS cloud.
  • can you provide more details about the function and what it does? Have you change any configuration of your Lambda after deploying? – Sri Mar 08 '23 at 11:24
  • My function is focused on validating content using apache Jena shacl Validator - https://jena.apache.org/documentation/javadoc/shacl/org.apache.jena.shacl/org/apache/jena/shacl/ShaclValidator.html . For a large content in SAM CLI it takes about ~9mins , but times out in the cloud. I have same memory, timeout and architecture configuration in both the cases. Should I be checking something else as well. – Shridha Jalihal Mar 08 '23 at 11:27
  • Is your lambda in default VPC? – mikipero Mar 08 '23 at 11:34
  • If you're confident that the issue is not network connectivity, then Increase the Lambda function's configured RAM to the maximum and retry. This will give it more RAM but also correspondingly more CPU. Let's see if it's simply a lengthy task. – jarmod Mar 08 '23 at 11:54
  • Tried this one too :) ran it at 10gb max memory. No luck. – Shridha Jalihal Mar 08 '23 at 11:56
  • Are you able to test against a smaller input as a baseline to compare to local runtime? – jarmod Mar 08 '23 at 11:58
  • Possible that you selected 2 subnets and of the subnet cannot reach the internet or the destination. By running on your SAM it sticks to the subnet that works, but running on AWS may sometimes be tied to a subnet that doesn't work. – Dominic Nguyen Mar 08 '23 at 12:15
  • @jarmod Tried with a decent input and it interestingly seems to be faster in the SAM CLI than AWS cloud. – Shridha Jalihal Mar 08 '23 at 12:40
  • @DominicNguyen Do subnets matter when the code is timing out while validating input which does not need an internet connection. – Shridha Jalihal Mar 08 '23 at 12:42
  • @Shridha Could you check if your function uses an external source to validate input? Maybe not internet but the same network resources or other AWS services (require internet if you don't VPC endpoints). – Dominic Nguyen Mar 09 '23 at 02:33
  • @DominicNguyen The validation is done using a maven dependency api https://mvnrepository.com/artifact/org.apache.jena/jena-shacl. The lambda in cloud is configured to access db resources in VPC. However, when I run the same code (db calls disabled) in cloud without the VPC configured, I dont see any improvements. – Shridha Jalihal Mar 09 '23 at 05:44

0 Answers0