NatLabRockies / NatLabRockies/openstudio-server-helm
Phase 2: MongoDB Replica Set StatefulSet for 10k-worker scaling
Nobody has claimed this yet.
- Dominant language
- Go Template
- Stars
- 12
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The single MongoDB pod (RWO PVC, Recreate strategy) is a critical SPOF with ceiling at ~3k-5k workers. Each worker writes 3+ status updates per job (queued→started→completed), generating ~30,000 writes/minute at 10k workers. A single pod faces write lock contention under 10k concurrent DataPoint updates, and any restart stalls all job progress tracking.
What Phase 1 Did
- Nothing yet — MongoDB was not modified in Phase 1
What Should Be Done (This Issue)
- Replica Set StatefulSet: Create a 3-pod
StatefulSettemplate (primary + secondary + arbiter) with headless service - Connection string update: Add replica set name to
MONGO_URIenv var in web/worker/web-background pods - Init container: Wait for replica set initialization before app starts
- PVC per pod: Each replica gets its own PVC (WiredTiger journal + data)
- Init job (optional): One-time job to initiate replica set with
rs.initiate()andrs.add() - Read preference: Configure
readPreference=secondaryPreferredfor reporting queries - Backup: Document
mongodumpormongodb-mongoshsidecar for periodic backups
Design Notes
- MongoDB 6.0+ replica set with PSArbiter (primary-secondary-arbiter) is standard for resource-constrained deployments
- Arbiter requires no PVC but adds the odd-numbered vote (3 total)
- WiredTiger cache size should be ~50% of available RAM per pod
- The
MONGO_URImust include?replicaSet=rs0&readPreference=secondaryPreferredfor proper routing - Phase 1 kept
db-deploy.yamlunchanged since this is a Phase 2 item
References
.agents/results/result-tf-infra.md— B2: Single MongoDB Instance (CRITICAL)openstudio-server/templates/db/db-deploy.yaml— current single-pod deploymentopenstudio-server/values.yaml—db.*config section
Acceptance Criteria
- 3-pod MongoDB StatefulSet with primary/secondary/arbiter roles
- Replica set auto-initializes on first deploy
- Connection string includes replica set name and read preference
- Failover to secondary completes in < 60s when primary is killed
- No data loss during failover (WiredTier journal enabled)
- Arbiter pod requires no PVC
- Backward compatible — single-pod mode still works (opt-in via values)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with openstudio-server/templates/db/db-deploy.yaml and the db.* section in openstudio-server/values.yaml; read .agents/results/result-tf-infra.md for the single-instance findings. Define the opt-in replica-set configuration, initialization, connection-string changes, PVC behavior, read preference, backup documentation, and failover checks against the listed acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- helm, kubernetes, mongodb
- Domain
- databases, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100