We have a java based AWS
lambda function which gets called through API Gateway about 10-15 times a day which is very less as per me.
The Lambda config has a memory of 1024 MB and timeout limit of 15 sec. But from the past week or so, the lambda function times out even after getting the response. And this occurrence is not uniform. It's sporadic. And eventually executes normally after some time.
We have tried optimizing the code and it shouldn't take more than ~8 sec to execute. Hoping to find a solution for this. Let me know if more info is needed.
Thanks in advance.
The issue is similar to this question: AWS Lambda function timing out
The only difference being the tech used: The above question used nodeJS and we use Java
--Update:
One more thing I have noticed is when the API
is hit after being idle for long, it takes more time to get executed than when you hit it consecutively.
I checked the logs and when I hit it for the 1st time it took roughly 7-8 secs to execute and just after 2 consecutive hits the response time reduced to a mere 2 secs.. Very strange...