MongoDB hosting runs the popular document database on servers you control, giving your applications a flexible data store with dedicated resources. Self-hosting MongoDB on a VPS or dedicated server avoids the usage-based costs of managed database services and keeps data in your chosen location. It suits applications with evolving schemas, content platforms, analytics and real-time services.
Sizing MongoDB correctly
MongoDB's WiredTiger storage engine performs best when the working set, the data and indexes your application uses frequently, fits in memory. Plan RAM based on that working set plus overhead for connections and the operating system. Use NVMe storage for fast writes and reads when data is not cached. CPU matters for aggregations, compression and many concurrent queries.
- RAM sized to the frequently accessed data and indexes
- NVMe storage for journal and data files
- XFS file system, recommended for WiredTiger
- Enough CPU cores for concurrent operations
Replica sets for reliability
Production MongoDB should run as a replica set, with at least three members, so the database fails over automatically if the primary becomes unavailable. Replica sets also enable consistent backups from secondary members without affecting the primary. Place members on separate servers, and consider one member in another location for disaster recovery.
Securing MongoDB
Many data breaches come from MongoDB instances exposed to the internet without authentication. Enable authentication and role-based access control, bind MongoDB to private interfaces or localhost and restrict access with a firewall. Use TLS for connections between application servers and replica set members. Keep MongoDB updated, and audit user permissions regularly.
Backups and maintenance
Use mongodump for smaller databases or filesystem snapshots for large ones, and store backups in another location. Test restores regularly. Monitor performance with built-in tools such as mongostat and the database profiler to find slow queries, and create indexes to support common query patterns. Review index usage periodically and drop indexes nobody queries, since every index slows down writes and uses memory.
Choosing the right plan
Development and small applications run on a VPS with moderate RAM. Production replica sets need several VPS instances or dedicated servers with large memory. Check RAM, storage type and private networking options in the plans below.