Recently I wanted to optimise the performance of MongoDB for test and development environments where persistent data storage and logging isn't important. I also wanted a solution that was easy to deploy and maintain across multiple development machines.

Although I haven't officially benchmarked my performance testing I found that the following configuration tweaks provided significant performance improvements:

  1. Disabling logging
  2. Enabling smallfiles
  3. Disable preallocation
  4. Use a ramdisk for storage

To make it easy to ship this setup between multiple machines and environments I opted to compile this into a docker image jamesridgway/mongo-tmpfs. The setup for this docker image is incredible simple and is purely mongo configuration:

  dbPath: /data/db
  engine: mmapv1
    enabled: false
    preallocDataFiles: false
    smallFiles: true
  destination: file
  logAppend: false
  path: /dev/null
  port: 27017

The full source for the docker image is available on github.

The following example shows how to launch the docker container with a ramdisk (note that --privileged is required for this).

$ docker run  --name mongo-tmpfs \
            --privileged \
            -p 27017:27017 \

Docker Hub: jamesridgway/mongo-tmpfs