Can I configure MongoDB to be In-Memory?

A performance boost approach you can take is to use a RAM disk

e.g.:

mongod --smallfiles --noprealloc --nojournal --dbpath <ramdisk mounted localtion>

See also:

  • http://edgystuff.tumblr.com/post/49304254688/how-to-use-mongodb-as-a-pure-in-memory-db-redis-style

  • Create RAM Disk linux: https://unix.stackexchange.com/questions/66329/creating-a-ram-disk-on-linux/66331#66331

  • http://www.phpmoadmin.com/mongodb-in-memory-database


As of today, latest version of MongoDB, i.e. v3.4 supports in memory engine in their Enterprise software edition. If you seek open source edition, Percona's MongoDB is way to go.

Mongo Enterprise edition : https://docs.mongodb.com/manual/core/inmemory/

Percona's MongoDB offering: https://www.percona.com/software/mongo-database/percona-memory-engine-for-mongodb


Using a tmpfs

At least on linux, since MongoDB uses memory mapped (mmap) files, you can set up a tmpfs system that resides in memory.

Here's a neat tutorial on setting up a tmpfs for MongoDB.

Memory mapped files

Memory mapped files are explained in more detail on their FAQ. It also says that MongoDB is automatically configured to use all available free memory on a system as its cache (link).

Conclusion

Basically, there is no module for a purely in-memory database, but by using an in-memory fs, one can emulate it.

On a side note, I did find MorboDB, a "In-memory database, mostly-compatible clone of MongoDB". Probably not useful to you, but I thought it interesting.