Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can concurrent docker containers speed-up computations?

As a disclaimer let me just say that I am a beginner with Docker and hence the question might sound a bit "dummy".

I am exploring parallelization options to speed-up some computations. I'm working with Python, so I followed the official guidelines to create my first image and then run it as a container.

For the time being, I use a dummy program that generates a very large np random matrix (let's say 4000 x 4000) and then finds how many elements in each row fall into a predefined range [min, max].

I then launched a second container of the same image obviously with a different port and name. I didn't get any speed-ups in the computations which I was expecting somehow, since:

  • a) I haven't developed any mechanism for the 2 containers to somehow "talk to each other" and share intermediate results
  • b) I am not sure if the program itself is suitable for speedups in such a way.

So my questions corresponding to a, b above are:

  1. Is parallelism a "feature" supported by docker deployments and in what sense? Is it just load sharing? And if I implement a load balancer, how does docker know how to transfer intermediate results from one container to the other?
  2. If the previous question is not "correct", do I then need to write "parallel" versions of my programs to assign to each container? Isn't this equivalent to writing MPI versions of my program and assign them to different cores in my system? What would be the benefit of a docker architecture then?

thanks in advance

like image 833
Jimakos Avatar asked Mar 28 '26 16:03

Jimakos


1 Answers

Docker is just a way of deploying your application - it does not in itself allow you to 'support' parallelism just by using Docker. Your application itself needs to support parallelism. Docker (and Kubernetes, etc) can help you scale out in parallel easily but your applications need to be able to support that scaling out.

So if you can run multiple instances of your application in parallel now (however you might do that) and it would not deliver any performance improvement then Docker will not help you. If running multiple instances now does improve performance then Docker will help scale out.

like image 197
JohnXF Avatar answered Mar 31 '26 05:03

JohnXF



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!