Start a unique Docker Container on demand for each visitor

5/20/2020

Situation: We got a webapp with 3 Docker Container (frontend, backend, database) (which I will call 'Unit' in the following context) and we would like to make a demo side where each visitor would get a unique Unit which does not live longer then for example 20 minutes of inactivity. The reason is, that we want each potential user to have a clean-state experience on the demo page. And specially, we don't want anyone to read anything (for example racist) that an other visitor has left behind.

Is something like this doable with Docker / k8s?

EDIT: It would not be a problem to hide this behind another website รก la "Click here to start the demo" which then would start up a new Unit before navigating.

TLDR: How to deploy a unique docker container for each visitor of our webapp.

-- dturnschek
containers
docker
kubernetes

1 Answer

5/22/2020

Is something like this doable with Docker / k8s?

Absolutely. I can see at least a two ways of achieving that with k8s.

  1. The Easy, but potentially expensive way (if you run k8s in a cloud).

You can combine these 3 containers (frontend, backend, database) into a single Pod and spin up a new pod for each user. One user - one Pod (or set of Pods if needed). This is easy, but can be very expensive (if you have a lot of users). The Pod can be later destroyed if it is not needed anymore.

  1. More complex, but not that expensive way.

If your software allows you running a frontend and backend that are the same for all the users, than it is possible moving "unique" content to the database. For example into some table/set of tables. In this case only a few pods will be constantly up instaed of "full set for each user". The data is stored in database.

You can flush the database periodically, to wipe out all the assets your users create during tests.

As a result you may end up with much smaller "footprint" compared to the first option.

Hope that helps.

-- Nick
Source: StackOverflow