I am new to aws lambda and I am moving my spring boot 2.x based project to lambda.But I am struggling with lambda cold-start and warm-up. I tried a few things mentioned in this link:https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot, but still the application takes around 45 secs to start.
Things I tried:
Async initialization from the above link. It did help a bit but not enough.
Skip the Init phase of the lambda. It helped reduce almost 8 secs.
Provisioned concurrency but as far as I could see, it is not helping either. When I saw the logs, the spring context is getting initialized every time, if any request comes after an interval of 15-20 mins.
The response time of my lambda in different scenarios is:
1. 3008 MB memory/first request/ response time: ~25 secs.
2. 3008 MB memory/2nd request immediately after 1st req/ response time: ~600ms.
3. 1024 MB memory/1st req/ postman request times out.
4. 1024 MB memory/2nd req immediately after 1st req/response time: ~750ms.
5. 1792 MB memory/1st req/ response time: ~27sec.
6. 1792 MB memory/ 2nd req immediately after 1st req/response time: ~650ms
To reduce this response time, I am thinking of making a REST call to my lambda every 5 or 10 mins so as to keep the spring context in memory and that in turn would help serve the requests faster. This call will be like a health check call, very less to no processing at all.
Is this an advisable approach? Or is there a better way of achieving this goal?
I am unclear about AWS will charge in this case.