<p>I have a bunch of api calls in my spring boot service. Let's say,</p>
<pre><code>http://localhost:8080/me/customize
http://localhost:8080/me/addItem
http://localhost:8080/me/revokeItem
</code></pre>
<p>When the user hit's <strong>http://localhost:8080/me/customize</strong> api, then I have to trigger a docker instance(and execute some code inside the spawned docker instance) and provide a unique id to the user. The user will use that unique id to hit the other apis.</p>
<p>This process should happen for all the users. Let us say that 100 users hit the customize api, i need to have 100 docker instances with a unique identifier tied to each docker instance and the user should use that unique id to communicate with the docker instance from there onwards.</p>
<p>Do I need to write java code to handle the docker spawning and mapping the unique id to each docker instance?</p>
<p>I am a tester and this is my first time dealing with development stuff. Could any of you point me in the right direction or some sort of tutorial may be? I have done googling, and still didn't found any answer.</p>

Kishore Mohanavelu
<blockquote>
<p>Do I need to write java code to handle the docker spawning and mapping
the unique id to each docker instance?</p>
</blockquote>
<p>Ideally you can but managing that would be hard if you use Kubernets job any other way. Using deployment would be easy however i would not suggest going that way. rather implement the Pub/sub or queue messaging if it's fine.</p>
<blockquote>
<p>I have to trigger a docker instance(and execute some code inside the
spawned docker instance) and provide a unique id to the user.</p>
</blockquote>
<p>i not sure what is the exact requirement or reason behind spawning new instance each time.</p>
<p>You can create the Pub/Sub or queue system when user will call the API it will the add payload into queue and further worker PODs will use that payload and process it one by one.</p>
<p>You can store the outcome or ID into <strong>Redis</strong> or <strong>MySQL</strong> and further use by other services or application if you need.</p>
<p>You can also use a queueing systems like RabbitMQ or a library like <a href="https://github.com/OptimalBits/bull" rel="nofollow noreferrer">https://github.com/OptimalBits/bull</a>.</p>
<p>You can create multiple worker replicas and they will subscribe to a single queue or channel and process the payload and save ID to database like Redis.</p>
<p>If there is a specific requirement of running replica for each process write code which will spwan the POD one by one may creating different deployment or Jobs.</p>
