Host MongoDB on VeloxaHost
MongoDB is a document database that stores records as flexible JSON-like documents, with rich queries, indexes, aggregation pipelines and replica sets. Developers self-host MongoDB Community for Node.js and Python applications, for chat platforms such as Rocket.Chat, and to avoid managed-database pricing.
The one-click app starts from Ubuntu 24.04 and installs MongoDB Community from MongoDB's own APT repository rather than Ubuntu's archive, and runs it as the mongod systemd service on port 27017. It installs the 8.0 series, the first that MongoDB supports on Ubuntu 24.04; mongod --version in the browser terminal on the server's page shows the exact release. The steps below are the same install done by hand, for a server you set up yourself.
The MongoDB manual covers installation, security and operations.
What it needs
MongoDB's production notes set two hard requirements worth knowing. On x86-64, MongoDB 5.0 and newer need a CPU with AVX, and each instance needs at least two real cores. Memory goes mostly to the WiredTiger cache, which by default takes the larger of 50% of (RAM minus 1 GB) or 256 MB; the notes advise against raising it above the default. On a 4 GB server that is 1.5 GB of cache, with the rest left to the filesystem cache, which MongoDB also uses.
That is why the recommended size is 2 vCPU and 4 GB of RAM, the Veloxa 2: 2 vCPU, 4 GB RAM and 80 GB of disk for $15 a month, billed at $0.03 an hour and capped at the monthly price. Size up when your indexes and frequently used documents no longer fit in the cache.
Install it yourself
These are MongoDB's steps for Ubuntu 24.04.
- Add MongoDB's signing key and the 8.0 repository.
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.0.list - Install and start it.
apt update && apt install -y mongodb-org systemctl enable --now mongod - Create an admin user with
mongosh, then turn on access control by addingsecurity:andauthorization: enabledto/etc/mongod.conf. - For remote clients, set
net.bindIpto0.0.0.0in/etc/mongod.confand restart. Every server gets a block of ports on the region's shared IPv4 address: under How to connect, forward a port of the block to 27017, and attach a VeloxaHost firewall that admits only your application's addresses. A dedicated IPv4 address is a paid add-on with limited availability. Private networks are not available in US East yet.
Backups and updates
Turn on automatic snapshots on the server page (hourly up to weekly, kept for 1 to 30 days) and scheduled backups (every 6 hours up to weekly, keeping 1 to 10). Keep logical backups too: mongodump and mongorestore, from the MongoDB Database Tools that the mongodb-org package installs, dump and restore one database or the whole server. A restore must target the same major version as the source.
Patch releases in the 8.0 series come from apt upgrade. A major upgrade goes one release at a time with the feature compatibility version raised in between, as MongoDB's upgrade notes describe; take a snapshot first.
FAQ
How much RAM does MongoDB need?
MongoDB states no fixed minimum, but its cache is half of the memory above 1 GB, so memory decides how much of your data is served from RAM. 4 GB (Veloxa 2) is a sensible start; raise memory from the console without a restart, then restart mongod so the default cache size is recalculated.
Which version should I run, and for how long is it supported?
MongoDB 8.0 is supported until October 31, 2029, according to MongoDB's lifecycle page. The 7.0 series is not supported on Ubuntu 24.04.
How do I move from MongoDB Atlas?
mongodump accepts an Atlas mongodb+srv:// connection string. Dump from Atlas, copy the files over, and mongorestore into your server, keeping the same major version. For large datasets with little downtime, MongoDB's mongosync tool is the alternative.
Does Rocket.Chat or another app need a replica set?
Rocket.Chat does, and change streams and transactions need one. A single-node replica set works: set replication.replSetName in mongod.conf, restart, and run rs.initiate() once.
What license is MongoDB Community under?
MongoDB Community Server is released under the Server Side Public License (SSPL) v1. It is free to use for your own applications; the SSPL's conditions matter if you offer MongoDB itself as a service to others.
Which VeloxaHost size fits MongoDB?
The recommended 2 vCPU and 4 GB of RAM is a Veloxa 2: 2 vCPU, 4 GB RAM and 80 GB of disk for $15 a month, billed at $0.03 an hour and capped at that price.