AWS API Gateway/Lambda 502 issues

Was having issues with a simple Lambda function written in python and exposed over the API gateway (in proxy mode).  All the function did was validate some incoming JSON using some json schema validator and drop the valid data into a redis set.

We got intermittent reports from the client that the requests were timing out. The first thing we tried was increasing the timeout beyond the 10 second default. It was believed that we had a cold start issue. This seemed like a probable cause since the errors happned at around 3am EST.

Some days it was fine. Some days it was worse. But still the issue persisted.  One proposal was to have a second service hitting the lambda function every minute to keep it ‘warm’. Before I did that, I tried increasing the ram available to the function from 128 to 512 MB. The docs imply that CPU will be proportionaly increased based on the amount of RAM.  After I did this, I have not received a single client support email!