I'm working on a multi-client app with a React frontend and a Spring Boot backend. Traffic is pretty light, with maybe a couple thousand requests daily. Right now, my backend runs on AWS Lambda via API Gateway, using a lightweight Spring Boot app to handle requests and return processed data to the frontend. While it mostly works, I'm facing issues with cold starts—initial requests take about 4-5 seconds while subsequent ones are quicker. I know this is typical since AWS keeps the Lambda warm only for a short time.
I've considered switching to EC2 to avoid these issues but want to keep costs down. I tried using Provisioned Concurrency with Lambda, but even with 50 instances set, I don't notice much of a difference in start times. Shouldn't Provisioned Concurrency be similar to having an always-on EC2 instance for my Spring Boot app? Am I missing something? Any tips would be greatly appreciated as I'm still learning about AWS!
2 Answers
You might want to check out AWS SnapStart. This feature optimizes cold start performance by using advanced priming strategies. It sounds like it could really help your setup! Here’s a link to the AWS blog that explains it: https://aws.amazon.com/blogs/compute/optimizing-cold-start-performance-of-aws-lambda-using-advanced-priming-strategies-with-snapstart/
The issue could be with Spring Boot itself. Consider switching to a faster booting language for your Lambdas, like Rust or Node.js; those typically start up much faster. You could also use CloudWatch to ping your Lambda every few minutes to keep it warm, but be cautious—it's not resource-efficient and might push you out of the free tier.
I’m already out of the free tier, so I’ll need to think about scaling as I onboard more clients. I do rely heavily on network calls and calculations in my app though, so I might explore rewriting some logic in Python or something lighter for better performance.
Thanks for the suggestion! I’ll definitely look into SnapStart and see how it might improve my Lambda performance.