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:
- Disabling logging
- Enabling smallfiles
- Disable preallocation
- 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:
storage: dbPath: /data/db engine: mmapv1 journal: enabled: false mmapv1: preallocDataFiles: false smallFiles: true systemLog: destination: file logAppend: false path: /dev/null net: 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 \ jamesridgway/mongo-tmpfs