[{"data":1,"prerenderedAt":123},["ShallowReactive",2],{"seo-verification":3,"blog-hosting-mongodb-on-a-vps-en":6},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"id":7,"slug":8,"slugs":9,"title":12,"excerpt":13,"readTime":14,"views":15,"isPinned":16,"publishedAt":17,"category":18,"categories":24,"featuredImage":26,"bgImage":27,"posterImage":28,"relatedSolution":26,"intro":29,"sections":30,"ctaTitle":73,"ctaBody":74,"ctaButton":75,"ctaUrl":76,"relatedPosts":77},59,"hosting-mongodb-on-a-vps",{"fr":10,"en":8,"ar":11},"heberger-mongodb-vps","استضافة-mongodb-على-خادم-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",{"id":19,"name":20,"slug":21,"color":22,"icon":23},6,"Databases","bases-de-donnees","bg-teal-500\u002F10 text-teal-400","database",[25],{"id":19,"name":20,"slug":21,"color":22,"icon":23},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.",[31,35,45,48,70],{"type":32,"title":33,"body":34},"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":36,"title":37,"items":38},"ul","The concrete benefits of a self-hosted MongoDB",[39,40,41,42,43,44],"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":32,"title":46,"body":47},"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":49,"title":50,"steps":51},"steps","Deploying MongoDB with Docker in production",[52,55,58,61,64,67],{"title":53,"body":54},"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":56,"body":57},"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":59,"body":60},"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":62,"body":63},"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":65,"body":66},"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":68,"body":69},"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":71,"body":72},"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",[78,95,108],{"id":79,"slug":80,"slugs":81,"title":84,"excerpt":85,"readTime":86,"views":15,"isPinned":16,"publishedAt":87,"category":88,"categories":89,"featuredImage":26,"bgImage":27,"posterImage":91,"relatedSolution":92},56,"postgresql-on-a-vps-a-reliable-and-controlled-database",{"fr":82,"en":80,"ar":83},"heberger-postgresql-vps","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.",4,"2026-04-25T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[90],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fheberger-postgresql-vps-poster.svg",{"categorySlug":93,"appSlug":94},"databases","postgresql-stack",{"id":96,"slug":97,"slugs":98,"title":101,"excerpt":102,"readTime":14,"views":15,"isPinned":16,"publishedAt":103,"category":104,"categories":105,"featuredImage":26,"bgImage":27,"posterImage":107,"relatedSolution":26},57,"hosting-mysql-on-a-vps",{"fr":99,"en":97,"ar":100},"heberger-mysql-vps","استضافة-mysql-على-خادم-vps","Hosting MySQL on a VPS","Host MySQL on your Cloud VPS: Docker deployment, hardening, InnoDB tuning, and automated backups, step by step.","2026-04-24T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[106],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fheberger-mysql-vps-poster.svg",{"id":109,"slug":110,"slugs":111,"title":114,"excerpt":115,"readTime":86,"views":15,"isPinned":16,"publishedAt":116,"category":117,"categories":118,"featuredImage":26,"bgImage":27,"posterImage":120,"relatedSolution":121},58,"hosting-redis-on-a-vps",{"fr":112,"en":110,"ar":113},"heberger-redis-vps","استضافة-redis-على-خادم-vps","Hosting Redis on a VPS","Deploy Redis on your Cloud VPS: in-memory cache, sessions, and queues, with persistence, security, and tuning.","2026-04-23T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[119],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fheberger-redis-vps-poster.svg",{"categorySlug":93,"appSlug":122},"redis-stack",1787661720317]