I am running a java service in docker which is basically a socket server. I am able to run this using docker container and able publish and expose the port on the host machine and able to connect using client. All okay so far.
This java service is single threaded and needs to be that way. So to be able to serve multiple requests concurrently, I need to be able to scale this - by spawning multiple docker containers on the fly to run on different ports.
I am thinking of writing a “listener” which will receive the requests from clients, spawn a docker container with the java service on a random port, share the ip and port to the client and from that point onwards, client will directly connect with the docker based java service. So basically write a broker to handle this using docker SDK. Does this approach sound correct ? is there any other better way of handling this ?