[{"data":1,"prerenderedAt":117},["ShallowReactive",2],{"seo-verification":3,"blog-heberger-mongodb-vps-en":6},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"id":7,"slug":8,"title":9,"excerpt":10,"readTime":11,"views":12,"isPinned":13,"publishedAt":14,"category":15,"categories":21,"featuredImage":23,"bgImage":24,"posterImage":25,"relatedSolution":26,"intro":28,"sections":29,"ctaTitle":72,"ctaBody":73,"ctaButton":74,"ctaUrl":75,"relatedPosts":76},59,"heberger-mongodb-vps","Hosting MongoDB on a VPS","Host MongoDB on your Cloud VPS: Docker deployment, replica set, authentication, indexing, and controlled backups.",8,583,false,"2026-04-22T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},6,"Databases","bases-de-donnees","bg-teal-500\u002F10 text-teal-400","database",[22],{"id":16,"name":17,"slug":18,"color":19,"icon":20},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fheberger-mongodb-vps-poster.svg",{"categorySlug":18,"appSlug":27},"mongodb","MongoDB is the reference document database for modern applications: flexible schema, rich queries, and horizontal scalability. Self-hosting it on a VPS frees you from Atlas's per-cluster costs and gives you full control over your indexes, your replica set, and your data retention.",[30,34,44,47,69],{"type":31,"title":32,"body":33},"h2","Why self-host MongoDB on a VPS","MongoDB Atlas bills per cluster, per GB, and per operation, and restricts certain features outside the premium tiers. By deploying MongoDB on your VPS, you set up a full replica set for high availability, you enable the profiler and the indexes you want, and you keep your documents on infrastructure you control. It's a good fit for a Node.js\u002FExpress application, a logging backend, a product catalog with a variable structure, or any system where the schema evolves quickly. With WiredTiger as the storage engine and proper RAM sizing for the working set, a VPS delivers performance entirely comparable to a managed instance, at a fraction of the cost.",{"type":35,"title":36,"items":37},"ul","The concrete benefits of a self-hosted MongoDB",[38,39,40,41,42,43],"A full replica set (primary + secondaries) across multiple VPSs for high availability.","Indexes and profiler without restriction: compound, partial, TTL, geospatial, full-text.","Control of the WiredTiger cache to keep the working set in memory.","No billing per operation or per cluster size: a predictable VPS plan.","Backups via `mongodump` or volume snapshots, depending on your data volume.","Sovereignty and full access to the server's logs, metrics, and configuration.",{"type":31,"title":45,"body":46},"Hardware and software prerequisites","MongoDB leverages RAM for its WiredTiger cache: aim to be able to fit your working set (the frequently accessed data and indexes) in it. For a development project or a small app, 2 vCPU and 4 GB of RAM with 40 GB of SSD are suitable. For production with a replica set, plan for 4 vCPU and 8 GB of RAM per node, and ideally three separate VPSs (one primary, two secondaries, or an arbiter for the quorum). On the software side: Ubuntu 22.04\u002F24.04 LTS, Docker and Compose v2, a persistent volume for `\u002Fdata\u002Fdb`, and an XFS file system recommended by MongoDB for WiredTiger. A domain is useful (e.g., `mongo.myapp.com`) if you expose access via TLS.",{"type":48,"title":49,"steps":50},"steps","Deploying MongoDB with Docker in production",[51,54,57,60,63,66],{"title":52,"body":53},"Prepare the VPS","Install Docker, disable Transparent Huge Pages (a MongoDB recommendation), and close port 27017 to the outside with `ufw deny 27017`. A MongoDB without authentication exposed on the Internet is an immediate ransomware target.",{"title":55,"body":56},"Define the docker-compose.yml","Declare a `mongo:7` service, mount a volume on `\u002Fdata\u002Fdb`, and pass `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` through `.env`. Add the `--auth` command to enforce authentication from startup.",{"title":58,"body":59},"Create the application users","After `docker compose up -d`, connect with `docker compose exec mongo mongosh`, then create a dedicated user for your database with the `readWrite` role only. Reserve the root account for administration, never for the application.",{"title":61,"body":62},"Enable the replica set","For high availability, start each node with `--replSet rs0`, then initialize with `rs.initiate()` listing the members. The replica set provides automatic failover and allows reads on the secondaries (`readPreference: secondary`).",{"title":64,"body":65},"Secure remote access with TLS","If an external app connects, enable TLS with a Let's Encrypt certificate mounted in the container (`--tlsMode requireTLS`), and use the internal key (`--keyFile`) to authenticate the replica set members with each other.",{"title":67,"body":68},"Index and back up","Create your indexes with `db.collection.createIndex()` while analyzing queries via `explain()`. Schedule a daily `mongodump` or, for large volumes, consistent volume snapshots, and archive them off the VPS.",{"type":70,"body":71},"tip","Enable the profiler in slow mode (`db.setProfilingLevel(1, { slowms: 100 })`) to capture queries exceeding 100 ms, then cross-reference the results with `explain('executionStats')`: most MongoDB performance problems come from a missing index that forces a COLLSCAN. For time series (logs, metrics), leverage the native time-series collections of MongoDB 5+: they compress automatically and dramatically reduce the disk footprint.","Deploy your MongoDB in full autonomy","With the ServOrbit Cloud VPS and its preconfigured Docker template, set up a MongoDB replica set on NVMe SSD with dedicated RAM, without per-cluster billing.","Configure my Cloud VPS","\u002Fvps-cloud",[77,90,104],{"id":78,"slug":79,"title":80,"excerpt":81,"readTime":11,"views":82,"isPinned":13,"publishedAt":83,"category":84,"categories":85,"featuredImage":23,"bgImage":24,"posterImage":87,"relatedSolution":88},56,"heberger-postgresql-vps","PostgreSQL on a VPS: a reliable and controlled database","Host PostgreSQL on a VPS: volumes, backups, restricted network access and sound configuration for your applications.",2240,"2026-04-25T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[86],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fheberger-postgresql-vps-poster.svg",{"categorySlug":18,"appSlug":89},"postgresql",{"id":91,"slug":92,"title":93,"excerpt":94,"readTime":95,"views":96,"isPinned":13,"publishedAt":97,"category":98,"categories":99,"featuredImage":23,"bgImage":24,"posterImage":101,"relatedSolution":102},57,"heberger-mysql-vps","Hosting MySQL on a VPS","Host MySQL on your Cloud VPS: Docker deployment, hardening, InnoDB tuning, and automated backups, step by step.",7,509,"2026-04-24T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[100],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fheberger-mysql-vps-poster.svg",{"categorySlug":18,"appSlug":103},"mysql",{"id":105,"slug":106,"title":107,"excerpt":108,"readTime":95,"views":109,"isPinned":13,"publishedAt":110,"category":111,"categories":112,"featuredImage":23,"bgImage":24,"posterImage":114,"relatedSolution":115},58,"heberger-redis-vps","Hosting Redis on a VPS","Deploy Redis on your Cloud VPS: ultra-fast cache, sessions, and queues, with persistence, security, and memory tuning.",546,"2026-04-23T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[113],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fheberger-redis-vps-poster.svg",{"categorySlug":18,"appSlug":116},"redis",1785628441937]