I'm working on a containerized application that acts as an API server, and I'm trying to create an Amazon Machine Image (AMI) for it. The app relies on loading very large files into memory when it starts up. I've noticed that the initial startup of the server takes over 10 minutes, which is really frustrating since it performs well and starts quickly (in just 2 seconds) on subsequent restarts. I'm aware that cold starts are usually unavoidable and that you can't pre-load data into memory before startup, but this long wait time for the first launch is quite bothersome. Any tips or advice on how to deal with this issue?
1 Answer
Just a thought, is your app built in Java? There's not much you can do with cold starts in that case, but if you're using AWS Lambda, there's a feature called SnapStart that helps with lengthy startup times. Not sure if ECS has any similar feature, though. Let me know if I'm wrong!

Actually, I’m using Python with FastAPI for this project. I can’t use Lambda because my app is GPU intensive.