google-ads-api
google-ads-api copied to clipboard
Using with AWS Lambda
Hey, can someone confirm I can use this with AWS Lambda?
I've been trying to use GAds API with lambda but my functions keep timing out. I've tried with 1 min timeout/ 1024 mb memory (although it only reaches 360mb max).
Locally it works well with the same config and function. My lambda is not in a VPC. I've tried different operations (query/mutate) with no success, even the simplest.
Thanks in advance for any experience shared.
To better define my environment if someone is getting the same behavior, I use:
- AWS-CDK (so it builds actually with esbuild to upload the zip)
- Node v14
The hardest part is that it doesn't error anywhere. I don't truly know if the error is on which side. It just hangs even if I try to list customers for a refresh key (that works locally)
Not much more help but should be noted Opteo is aware of some of the challenges of running inside Lamba environments:
https://github.com/Opteo/google-ads-node/issues/17
Thanks, @rosslavery ! A lot clearer to know there is WIP or even just not fully explored yet. Then I know I am not missing something obvious. :)
I have another experience. This was with google cloud run
that is slightly different but maybe AWS lambda works in a similar manner. What I have experimented* is that the resource attibution for a single run follow this steps:
- An externat trigger fire the execution (http requesto, scheduling etc etc)
- Resources was assigned to the runner (ram, cpu) etc etc
- Call to your code
- wait for response
- Resource deallocation
- Wait the runner gracefully shut down
Now if in my code I do this:
- handle the request
- do the hard work
- respond to the http request
- gracefull shutdown
all go as expected... BUT if I do this:
- handle the requeste
- respond to the http request
- do the hard work
- gracefull shutdown
here the job take a very long time and reach the timeout because after point 2
and before point 3
google remove all the allocated resources and leave only something very neglettable waiting your complete shutdown.
So the poin is: are you sure that you do the hard memory consuming work on the right place ? Maybe this is something that happen only in google cloud but keep me almos an entire day before debug the problem... so maybe a double check can be usefull.
* The experiment was done some months ago so maybe in the meantime things are changed and actually I don't find the docs where this behaviour was documented.