I’m developing a Laravel application that uses the AWS Lambda service for heavy lifting Python functions whose usage is very lumpy and unpredictable sometimes every few minutes, sometimes every few weeks.
Wow – that’s sounds like a perfect Lambda case study right? Well I thought so but due to weird, inconsistent and intermittent issues with AWS Lambas, I’m seriously considered simply scaling up my webservers and running all python functions locally.
Just in case I’m not alone in this, I thought I’d document my issues to see if they help any kindred spirits out there:
AWS Issue 1#: Credentials must be an instance of ‘Aws\Credentials\CredentialsInterface, an associative array that contains “key”, “secret”, and an optional “token” key-value pairs, a credentials provider function, or false.
This is without a doubt the most frustrating error I get from my application simply because a function works perfectly for weeks and then all of a sudden, starts kicking up this error, despite the fact that all my other Lambda calls use the exact same code for the credentials.
At the time of writing, I’m assuming that this is something that corrupts within the Lambda itself because recreating an identical Lambda and calling that instead solves the issue. Go figure.
AWS Issue 2#: Resources for the function are being restored errors
After taking a brief vacation, I came back and started using my application and found all of a sudden, all the AWS Lambda calls were failing wih an error of “resources for the function are being restored”.
Hark! I cried – what the hell is going on? Has Jeff Bezos taken offense to my holiday? Has my account been hacked and people scaled down memory on my Lambdas?
In short, what the f**k is going on?
Well it turns out the explanation is more pedestrian – it seems if you don’t use a Lambda for a while, AWS pulls the server resources from it and puts in idle mode. And they do not wake up quickly.
Well that’s some dam fine smallprint for you. I’m now having to write a function that nudges my Lambdas twice per day to keep them awake.