Files
tiennm99 e2e3112eb5 feat(db): finalize MongoDB Atlas migration documentation
Phase 08: Complete documentation pass for MongoDB Atlas migration.

- Create docs/cost-tracking.md: Cost monitoring, upgrade triggers, monthly checklist
- Create docs/project-changelog.md: Full migration summary with phase breakdown
- Update docs/architecture.md section 8: Describe dual-write era, MongoDB store layers
- Update docs/code-standards.md: Add Persistence section for storage factory patterns
- Update docs/codebase-summary.md: Reflect MongoDB as primary, update test count (733)
- Update README.md: Storage section now describes MongoDB + dual-write during migration
- Update CLAUDE.md: Architecture section references MongoDB instead of KV/D1
- Update tests/fakes/fake-mongo.js: Document frozen surface (Phase 02-08 API)

Verified:
- All 733 tests passing
- Lint + secret-leak check pass
- npm run register:dry succeeds
- Auto-pause concern satisfied: trading (17:00), lolschedule (01:00), drift-verifier (hourly) all write to Mongo
- Roadmap verified migration NOT listed (future-only per user feedback)

Post-Phase-07 cutover: dual-write collapses, KV/D1 deleted, MongoDB becomes sole backend.
2026-04-26 09:34:25 +07:00

2.7 KiB
Raw Permalink Blame History

MongoDB Atlas Cost Tracking

Operational runbook for monitoring and managing MongoDB Atlas billing during and post-migration.

Free Tier Limits (M0)

Resource Limit Warning
Storage 512 MB Reached 400 MB: prepare upgrade plan
Connections 500 Reached 400: review cron/handler concurrency
Throughput ~100 ops/sec sustained Degradation: check dashboard Charts
Backups None No PITR; only daily snapshots (read-only)

Cost Ladder

Tier Monthly When Ops/sec Storage
M0 Free Initial, dev ~100 512 MB
Flex $8$30 Sustained >400 MB or >400 conn 4001000 10256 GB
M10 $57 Production high-throughput 1000+ Unlimited

Flex tier auto-scales cost based on data volume and throughput. Start at M2 ($9) and scale to M5 ($70+) as needed.

Monitoring & Upgrade Triggers

Monthly Review Checklist

  1. Storage: Open Atlas Dashboard → Metrics → check Database Storage chart

    • If > 400 MB: escalate to Flex within 2 weeks
    • Projection: (current MB / days since epoch) * 30 → projected month-end
  2. Connections: Metrics → check Current Connections peak

    • If > 400: cron jobs or handlers running concurrently too often
    • Review src/modules/*/index.js cron frequency; stagger if possible
  3. Throughput: Metrics → Network Egress + Database Operations

    • Spike during trading/wordle command storms: expected
    • Sustained >100 ops/sec: assess Flex upgrade
  4. Cluster Status: Alerts → check if "Cluster unavailable" triggered

    • M0 never pauses if any cron writes data (bot has 6+ crons, any write prevents pause)

Upgrade Decision

Plan upgrade before hitting limits:

Condition Action Timeline
Storage trend → 512 MB in 3 months Upgrade to Flex M2 2 weeks notice
Peak connections > 400 regularly Upgrade to Flex M2 Immediate if sustained
Ops/sec spikes > 2000 Upgrade to Flex M5 or M10 1 week notice

Rotation & Maintenance

  • Password rotation: Every 90 days, owner = repo maintainer. See docs/using-mongodb.md "Rotation" section.
  • Alert config review: Monthly, ensure Atlas + CF Observability alerts are wired.
  • Backups: M0 has none; data is live-only. Backups start at Flex tier.

Post-Cutover Simplification

Once Phase 07 cutover completes and Cloudflare KV/D1 are deleted, MongoDB becomes the sole data store. Cost is dominated by storage growth (KV reads/writes are gone). Rebaseline this doc:

  • Remove dual-write cost considerations
  • Focus on pure Mongo spend
  • Extend storage projections based on new single-source data