2

I am running a SQL RDS with AWS Serverless, and run into errors when I test APIs. At the beginning of the day I will get a 502 error, however this resolves after I retry 1-4 times. I believe this error is due to some 'deadtime' that occurs when serverless is trying to 'boot up' from 0 capacity units after a period of inactivity? This does not seem to occur when the server is idle at 1 cap unit.

The only solution I have been able to think of is setting the server capacity min to 1 but this seems to defeat the purpose of serverless + increases price.

Has anyone else run into this problem/successfully implemented a solution?

Nina
  • 99
  • 8

1 Answers1

1

Before you run the API tests, you can start a paused serverless DB by sending it a scale command:

aws rds modify-current-db-cluster-capacity --db-cluster-identifier mydatabase --capacity 1

and then poll every few seconds to see if it is available:

aws rds describe-db-clusters --db-cluster-identifier mydatabase | jq -r '.DBClusters[].Status'

Once it is available you should be able to test your APIs without getting 502 errors.

enharmonic
  • 819
  • 8
  • 22
  • I have been curl-ing a healthcheck function until I get a successful response. Like your suggestion, this works as a warmup in development, but is not practical for a production stage where I want the db to be available to scale on command. – Nina Feb 20 '20 at 05:01