How to spin up 'n' instances of an app / container with pre-loaded memory

9/24/2018

Background: I have a language processing java app that requires about 16MB memory and takes about 40 seconds to initialise resources into that memory before exposing a webservice. I am new to containers and related technologies so apologies if my question is obvious...

Objective: I want to make available several hundred instances of my app on-demand and in a pre-loaded/ pre-configured state. (eg I could make a call to AWS to stand-up 'n' instances of my app and they would be ready in <10seconds.)

Question: I'm anticipating that I 'may' be able to create a docker image of the app, initialise it and pause hence be able to clone that on demand and 'un-pause' ? Could you advise whether what I am looking to do is possible and if so, how you would approach it.

AWS is my platform of choice so any AWS flavoured specifics would be super helpful.

-- user1134477
amazon-ecs
amazon-elastic-beanstalk
docker
kubernetes

1 Answer

9/24/2018

I'd split your question in two, if you don't mind:
1. Spinning up N containers (or, more likely, scale on demand)
2. Preloading memory.

#1 is Kubernetes's bread and butter and you can find a ton of resources about it online, so allow me to focus on #2.

The real problem is that you're too focused on a possible solution to see the bigger picture:
You want to "preload memory" in order to speed up launch time (well, what do you think Java is doing in those 40s that the magick memory preloader wouldn't?).

A different approach would be to launch the container, let Java eat up resources for 40s, but not make that container available to the world during that time.
Kubernetes provides tools to achieve exactly that, see here:
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/

Hope this helps!

-- samhain1138
Source: StackOverflow