[{"data":1,"prerenderedAt":138},["ShallowReactive",2],{"seo-verification":3,"blog-hosting-mongodb-on-a-vps-ma-en":6,"promo-bar-likely":137},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"key":7,"data":8},"blog-hosting-mongodb-on-a-vps-ma-en",{"id":9,"slug":10,"slugs":11,"title":15,"excerpt":16,"readTime":17,"views":18,"isPinned":19,"noindex":19,"publishedAt":20,"updatedAt":21,"category":22,"categories":28,"featuredImage":30,"bgImage":31,"posterImage":32,"relatedSolution":30,"intro":33,"sections":34,"ctaTitle":77,"ctaBody":78,"ctaButton":79,"ctaUrl":80,"relatedPosts":81},59,"hosting-mongodb-on-a-vps",{"fr":12,"en":10,"ar":13,"es":14},"heberger-mongodb-vps","استضافة-mongodb-على-خادم-vps","alojar-mongodb-en-un-vps","Hosting MongoDB on a VPS","Host MongoDB on your Cloud VPS: Docker deployment, replica set, authentication, indexing, and controlled backups.",3,0,false,"2026-04-22T00:00:00+00:00","2026-09-08T22:00:02+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},6,"Databases","bases-de-donnees","bg-teal-500\u002F10 text-teal-400","database",[29],{"id":23,"name":24,"slug":25,"color":26,"icon":27},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fheberger-mongodb-vps-poster.svg","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.",[35,39,49,52,74],{"type":36,"title":37,"body":38},"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":40,"title":41,"items":42},"ul","The concrete benefits of a self-hosted MongoDB",[43,44,45,46,47,48],"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":36,"title":50,"body":51},"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":53,"title":54,"steps":55},"steps","Deploying MongoDB with Docker in production",[56,59,62,65,68,71],{"title":57,"body":58},"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":60,"body":61},"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":63,"body":64},"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":66,"body":67},"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":69,"body":70},"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":72,"body":73},"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":75,"body":76},"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 SSD with dedicated RAM, without per-cluster billing.","Configure my Cloud VPS","\u002Fvps-cloud",[82,102,119],{"id":83,"slug":84,"slugs":85,"title":89,"excerpt":90,"readTime":91,"views":92,"isPinned":19,"noindex":19,"publishedAt":93,"updatedAt":94,"category":95,"categories":96,"featuredImage":30,"bgImage":31,"posterImage":98,"relatedSolution":99},56,"postgresql-on-a-vps-a-reliable-and-controlled-database",{"fr":86,"en":84,"ar":87,"es":88},"heberger-postgresql-vps","postgresql-على-خادم-vps-قاعدة-بيانات-موثوقة-ومتحكم-بها","alojar-postgresql-en-un-vps","PostgreSQL on a VPS: reliable, controlled database","Host PostgreSQL on a VPS: production config, pgBackRest backups, streaming HA, RDS\u002FSupabase\u002FNeon comparison and OOM troubleshooting.",9,1,"2026-04-25T00:00:00+00:00","2026-10-21T15:21:37+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[97],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fheberger-postgresql-vps-poster.svg",{"categorySlug":100,"appSlug":101},"databases","postgresql-stack",{"id":103,"slug":104,"slugs":105,"title":109,"excerpt":110,"readTime":91,"views":18,"isPinned":19,"noindex":19,"publishedAt":111,"updatedAt":112,"category":113,"categories":114,"featuredImage":30,"bgImage":31,"posterImage":116,"relatedSolution":117},57,"hosting-mysql-on-a-vps",{"fr":106,"en":104,"ar":107,"es":108},"heberger-mysql-vps","استضافة-mysql-على-خادم-vps","alojar-mysql-en-un-vps","Hosting MySQL on a VPS: complete guide","Install MySQL 8.4 LTS on a VPS: prerequisites, security hardening, InnoDB performance, secure remote access, automated backups, and troubleshooting.","2026-04-24T00:00:00+00:00","2026-11-09T20:55:18+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[115],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fheberger-mysql-vps-poster.svg",{"categorySlug":100,"appSlug":118},"mysql-stack",{"id":120,"slug":121,"slugs":122,"title":126,"excerpt":127,"readTime":128,"views":18,"isPinned":19,"noindex":19,"publishedAt":129,"updatedAt":130,"category":131,"categories":132,"featuredImage":30,"bgImage":31,"posterImage":134,"relatedSolution":135},58,"hosting-redis-on-a-vps",{"fr":123,"en":121,"ar":124,"es":125},"heberger-redis-vps","استضافة-redis-على-خادم-vps","alojar-redis-en-un-vps","Hosting Redis on a VPS: the complete guide","Deploy Redis on your Cloud VPS: RAM\u002FCPU requirements, security (ACL, TLS), RDB\u002FAOF persistence, troubleshooting, and high availability.",10,"2026-04-23T00:00:00+00:00","2026-09-08T21:59:59+00:00",{"id":23,"name":24,"slug":25,"color":26,"icon":27},[133],{"id":23,"name":24,"slug":25,"color":26,"icon":27},"\u002Fblog\u002Fcovers\u002Fheberger-redis-vps-poster.svg",{"categorySlug":100,"appSlug":136},"redis-stack",true,1794270418597]