MongoDB Replica Set
3-node MongoDB 8 replica set (rs0) on the stock image - self-initiating, internal-only, Atlas-shaped without the Atlas bill.
One-click deploy, from $25/mo on a Miget plan.
A single MongoDB container is fine until it restarts mid-write. A replica set is the unit of production MongoDB: automatic failover, rollback safety, and the topology that change streams and transactions actually require. This template runs a 3-member replica set (rs0) on the stock mongo image - the --replSet flags ride each service’s command, no custom build.
A tiny rs-init sidecar waits for the members, runs rs.initiate() exactly once (idempotent - re-runs detect the initialized set and skip), then idles at a hard 128 MiB cap. Each member keeps its data on its own 10 GB volume.
Everything is internal-only by design: this template ships without auth, so the project network is the security boundary - exactly like a VPC-peered Atlas cluster, minus the bill. Apps connect with the standard multi-host connection string and get driver-level failover for free.
Upstream project: MongoDB
#what you get
- MongoDB 8, 3-member replica set rs0 - transactions and change streams work
- Stock mongo image with command passthrough; no custom image to maintain
- Idempotent self-initialization (rs-init sidecar, 128 MiB)
- Automatic primary election and driver failover on node loss
- Per-member 10 GB persistent volumes
- Internal-only: never exposed to the internet
#topology
| Service | Role | Public |
|---|---|---|
| mongo-1..3 | replica-set members (:27017) | no |
| rs-init | one-time rs.initiate(), then idles | no |
#miget sizing
// this stack needs
3.1 GiB RAM · 30 GB disk · 4 services
1 GiB per member suits small-to-medium working sets; WiredTiger sizes its cache to the container limit. Grow volumes with your data - 10 GB each is the starting point.
Hobby - recommended fit
$25/mo
2 vCPU · 4 GiB · 80 GiB disk
Headroom for your own apps: 8 GiB at $49/mo
Professional - production
$85/mo
4 vCPU · 8 GiB · 50 GiB disk
Dedicated resources, production SLOs - plan details
One Miget plan is a fixed pool of compute - the whole stack (managed databases included) deploys inside it, and anything left over runs your other apps. No per-service or per-seat math.
#vs. the managed service
What the hosted equivalents charge, against the flat Miget plan this stack fits on. Prices as of June 2026, sources linked.
| Service | Plan | Monthly | What you get |
|---|---|---|---|
| MongoDB Replica Set on Miget ★ | 4 GiB plan | $25 | this whole stack, flat - no usage meters, and room left for your own apps |
| MongoDB Atlas | M10 dedicated | ~$57 | 3-node replica set, 2 GB RAM per node, 10-128 GB storage |
| MongoDB Atlas | Flex | usage-based | usage-tiered, capped $8-30/mo - shared infrastructure, the pre-dedicated entry point |
#vs. other PaaS
Estimated monthly cost of running this exact stack (3.1 GiB RAM, 30 GB disk, 4 containers) elsewhere, from published June 2026 rates.
| Platform | Est. monthly | Notes |
|---|---|---|
| Miget ★ | $25 flat | compose stacks first-class: one deploy, dedicated vCPU, managed Postgres/Valkey, volumes and TLS all included in the plan |
| Heroku | ~$156 | no volumes; nothing between 1 GB ($50) and 2.5 GB ($250) dynos - 2 GB containers cost far more than shown |
| Render | ~$47 | per-service instances (0.5 GB $7, 2 GB $25) - every container is its own paid service |
| DO App Platform | ~$43 | no persistent volumes - stateful containers need managed DBs/Spaces (base $5 Spaces included here) |
| Railway | ~$36 | usage-based ($10/GB RAM-mo); vCPU billed separately at $20/vCPU-mo on top |
| Fly.io | ~$23 | cheapest sticker price - but burstable shared CPUs (1/16 core; dedicated vCPUs cost ~2-3×), no compose deploys (one app per container, manual wiring), managed DBs billed extra |
Estimates assume RAM fully allocated at published on-demand rates - and sticker price isn't the whole comparison: the cheaper rows buy burstable shared CPUs, per-service wiring instead of a compose deploy, and managed databases billed separately. Heroku and DO App Platform have no persistent volumes at all - stateful stacks like this one need workarounds there.
#deploy it
On Miget
- Create a Compose Stack in app.miget.com pointing at the templates repository
- Set the stack path to
mongodb - No required variables - deploy as-is
- Deploy. Miget layers
compose.miget.yaml(RAM, privacy, volumes, managed services) automatically
Locally first?
Every template is portable, vanilla Docker Compose - the Miget overrides are ignored locally:
git clone https://github.com/deployable-sh/stacks
cd miget-compose-templates/mongodb
docker compose up -d Same files, same behavior. The template README covers connection strings and scaling notes.
#faq
How much cheaper is this than MongoDB Atlas?
Atlas M10 - its smallest dedicated tier - runs about $57/month for one 2 GB node-equivalent cluster. This 3-member replica set fits the 4 GiB Miget hobby plan at $25/month flat, with capacity left for the apps that use it.
Why a replica set instead of a single mongod?
Failover, durability, and features: multi-document transactions and change streams require a replica set. With three members, the set survives any single node failure with automatic primary election - your driver reconnects on its own.
How do applications connect?
From the same Miget project: mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/?replicaSet=rs0. Listing all members lets the driver discover the topology and fail over automatically.
Is it safe to run MongoDB without authentication?
Only because nothing outside the project network can reach it: all members are private with no ingress route, the same trust model as a database inside a VPC. Never expose these services publicly; if you need cross-project access, add keyfile auth first.
Can I use this for transactions and change streams?
Yes - both require a replica set, which is exactly what this is. Point your ODM (Mongoose, Prisma, Spring Data) at the rs0 connection string and they work out of the box.
Ship MongoDB Replica Set today
One compose stack, 3.1 GiB of RAM, from $25/month flat, and it runs on your laptop with the same files.