🍃
Hosting

MongoDB: Atlas cloud or your own server — which to choose

07.11.2026
← All articles

MongoDB is a document database that stores JSON-like documents instead of table rows, and many Node.js and Python apps choose it for its flexible schema. The next question is where to run it: a managed cluster in MongoDB's Atlas cloud service, or MongoDB installed and managed on your own VPS. Both have clear trade-offs.

MongoDB and shared hosting

Shared hosting usually offers MySQL and sometimes PostgreSQL, but almost never MongoDB, because it is a separate always-on server process that needs a fair amount of RAM. The real choice is between a managed service such as Atlas and your own server on a VPS.

Atlas: ready cluster, little admin work

An Atlas cluster is ready in minutes, and the service handles installation, upgrades, replication and monitoring, with automated backups on paid clusters. A free starter cluster exists for experiments, but its size and features are limited, so do not build a production business on it. Prices and plan terms change; check the official site.

The most common connection failure is forgetting to add your app server's IP to the Atlas network access list. Adding 0.0.0.0/0 makes the error go away but exposes the database to the whole internet; add only your server's specific IP.

// .env
// MONGO_URI=mongodb+srv://app:PAROL@cluster0.abcde.mongodb.net/dostavka

const { MongoClient } = require('mongodb');

const client = new MongoClient(process.env.MONGO_URI);
await client.connect();
const orders = client.db('dostavka').collection('orders');
await orders.insertOne({ phone: '+998901234567', total: 85000, createdAt: new Date() });

Latency and data location

Atlas runs in regions of large cloud providers, none of them inside Uzbekistan. With the app in Tashkent and the database abroad, every query crosses the border and back, and a page that makes dozens of queries feels slow. Uzbekistan also requires citizens' personal data to be stored on servers located in the country. If your database holds customer names, phone numbers or addresses, check the current rules with official sources or a lawyer before putting it in a foreign cloud.

Example: a Tashkent delivery startup

A small food delivery startup built its Node.js app on a free Atlas cluster and validated the idea quickly. As orders grew, the courier app became slow, the free tier limits came close and the orders contained customer phones and addresses. The team moved the database onto a VPS in Uzbekistan, on the same server as the app.

Self-hosting: install and lock down

Install MongoDB Community Edition from the official MongoDB repository, following the official instructions for your version. Then bind it to localhost and enable authentication:

# /etc/mongod.conf
net:
  port: 27017
  bindIp: 127.0.0.1
security:
  authorization: enabled

Create an admin user and a separate app user that can only read and write its own database, then run sudo systemctl restart mongod.

mongosh
use admin
db.createUser({ user: "admin", pwd: passwordPrompt(), roles: [ { role: "root", db: "admin" } ] })

use dostavka
db.createUser({ user: "app", pwd: passwordPrompt(), roles: [ { role: "readWrite", db: "dostavka" } ] })
MONGO_URI=mongodb://app:PAROL@127.0.0.1:27017/dostavka?authSource=dostavka

Multi-document transactions require a replica set, even a single-node one, and a replica set with authentication also needs a key file; follow the official docs for that step.

Memory and backups

By default WiredTiger uses the larger of 50% of (RAM − 1 GB) or 256 MB for its cache. On a small VPS shared with the app, cap it with storage.wiredTiger.engineConfig.cacheSizeGB. Back up daily with mongodump via cron and copy archives off the server.

mongodump --uri="mongodb://app:PAROL@127.0.0.1:27017/dostavka?authSource=dostavka" \
  --archive=/backup/dostavka-$(date +%F).gz --gzip

mongorestore --uri="mongodb://app:PAROL@127.0.0.1:27017/dostavka?authSource=dostavka" \
  --archive=/backup/dostavka-2026-11-04.gz --gzip --drop

Which to choose

CriterionAtlasOwn server (VPS)
Time to startMinutesInstall and configure
Admin workMostly the serviceUpdates, backups, monitoring on you
Latency from UzbekistanHigher, foreign regionMinimal next to the app
Personal data locationAbroadCan stay in Uzbekistan
ControlWithin service limitsFull

Atlas suits experiments, prototypes and projects with a mostly foreign audience, especially without an in-house admin. For projects serving users in Uzbekistan, storing personal data and sensitive to speed, a self-hosted MongoDB on a local VPS is usually the better choice; you can order one from the sayt.uz cabinet.

Related articles

💽 Disk full: 500 errors, a broken .htaccess and repairing the database 🗄️ Caching static files in Nginx: Cache-Control, expires and versioning 🐘 Creating a PostgreSQL database on hosting and connecting your site 📦 Backup plugins fill up your disk: configuring UpdraftPlus and others properly
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓