Home > Software design >  MongoDB Performance in Docker
MongoDB Performance in Docker

Time:10-13

I did an experiment by running a python app that is writing 2000 records into mongoDB.

The details of my setup of the experiment as follows:

Test 1: Local PC - Python App running on Local PC with mongoDB on Local PC (baseline) Test 2: Docker - Python App on Linux Container with mongoDB on Linux Container with persist volume Test 3: Docker - Python App on Linux Container with mongoDB on Linux Container without persist volume

I’ve generated the result in chart - on average writing data on local PC is about 30 secs. Where else on Docker, it takes about 80plus secs. Hence it seems like writing on Docker is almost 3 times slower than writing on local PC itself.

Should I want to improve the write speed or performance of the mongoDB in docker container, what is the recommended practice? Or should I put the mongoDB as a external volume without docker?

Thank you!

graph

CodePudding user response:

  1. Your system is not consistent in many ways - dynamic storage and CPU performance, other processes, dynamic system settings etc. There are a LOT of underlying things under storage only.
  2. 60 sec tests are not enough for anything
  3. Simple operations are not good enough for baseline comparisons
  4. There is ZERO performance impact with storage and CPU in case of containers, there is an impact in networking, but i assume, this is not applicable here
  5. Databases and database management systems must be optimized in special ways, there is no "install and run" approach. We, sysadmins/db admins usually need days to have it running smoothly. Also, performance changes over time.

CodePudding user response:

After couple of weeks of testing and troubleshooting. I finally got the answer and I shall share my findings with the rest of the DevOps or anyone who facing the same issue as me

Correct this statement if needed, Docker Container was started off with Linux, Microsoft join the container bandwagon late and in order to for the container works (with Linux), the DevOps team need to install Linux WSL2 in Windows. And that cost extra overheads which resultant in the process speed.

So to improve the performance speed with containers, the setup should be in Linux OS instead of Windows OS. (and yes the speed reduce drastically)

  • Related