MongoDB replica set design for Rocket.Chat

Rocket.Chat 8.x needs MongoDB 8.0 or later running as a replica set. This page covers how to design that database: member count, hosting model, connection strings and where backups live.

On this page

Why the MongoDB replica set is the first design decision for Rocket.Chat

Decide how the database runs under Rocket.Chat before go-live, because the choice shapes every later decision about hosting, sizing and recovery. Rocket.Chat 8.x requires MongoDB 8.0 or later running as a replica set, and a three-member replica set is strongly recommended for high availability. A standalone MongoDB server is not a supported shape for 8.x, so the question for your team is not whether to use a replica set but where its three members will run and who operates them. Confirm the exact minimum patch level against the current system requirements before you pin versions.

MongoDB holds the core of the workspace: users, rooms, subscriptions, message history, settings and the state that lets instances coordinate. Losing it means losing the workspace, and files kept in GridFS add to that footprint. According to the reference architectures, a single Rocket.Chat instance backed by a MongoDB replica set is the design they suggest up to 500 concurrent users. Above that, multiple load-balanced instances linked by NATS change the database picture, because every instance reads and writes the same replica set and connection counts, oplog volume and failover behavior all grow. Multi-instance designs require a paid plan, so confirm licensing before you size the database for them.

Treat the database as the design decision that sets your recovery objectives. Ask whether your operations team will run the replica set on your own virtual machines, through the Kubernetes operator, or through a managed MongoDB service, and whether that service can provide the replica set topology and connection behavior Rocket.Chat expects. Record who restores the data, where the third member and backups sit, and how many concurrent users you expect in year one. Those answers determine the connection string you hand to each instance and the backup placement you test before any upgrade.

How many members a Rocket.Chat replica set needs

Rocket.Chat 8.x runs on a MongoDB replica set, and the member count decides how much of the database survives a failure. The cards below cover the three-member recommendation, what each member does, what a single node cannot protect against, and how the count connects to the reference architecture tiers.

Start with three members

Rocket.Chat's system requirements strongly recommend a three-member replica set for high availability. Three members let the set keep a primary through the loss of one node, because the remaining two can still hold an election. Check that the three members sit on separate hosts or failure domains. Three members on one hypervisor still share one failure point.

Minimum MongoDB line
8.0
System requirements

The primary takes all writes

The primary accepts writes from every Rocket.Chat instance and records them in the oplog that secondaries replicate. If the primary fails, the remaining members elect a new one, and Rocket.Chat instances reconnect through the connection string. Confirm that your application timeouts tolerate an election pause, since messages sent during the gap can fail and need retrying from the client.

Secondaries hold the copies

Each secondary holds a full copy of the data and can take over as primary. Two secondaries mean the data survives two simultaneous member failures without an election stalling on a single survivor. Ask your DBA whether reads are ever directed to secondaries, because Rocket.Chat's read preference settings determine whether a lagging secondary can serve stale data.

Single node is not a replica set

A standalone MongoDB or a one-member replica set protects against process crashes only if the host restarts cleanly. It does not survive disk loss, host failure or a bad write that replicates everywhere, and it leaves no failover target. Rocket.Chat 8.x requires a replica set, so a single member is useful for test environments and not for production availability. Backups still matter on any topology.

Tie the count to reference tiers

Rocket.Chat's reference architectures suggest one instance with a MongoDB replica set up to 500 concurrent users, load-balanced instances linked by NATS above 500, and microservices on Kubernetes above 5,000. The member count does not change by tier, but the database load does, so plan the member hardware against the tier you expect. The multi-instance and microservice designs require a paid plan. Confirm the user counts you will sustain before choosing sizes.

Reference architectures

Hosting options for the Rocket.Chat database

This table compares three ways to run the MongoDB replica set behind Rocket.Chat: self-managed on virtual machines, the Kubernetes operator inside your cluster, and a managed MongoDB service. Read each row as a question to answer with your own platform team before choosing, since the answer usually depends on who already runs database operations in your organization.

Decision pointSelf-managed MongoDB on VMsKubernetes operator in the clusterManaged MongoDB service
Who patches MongoDBYour database or platform team, on their own scheduleYour team, with the operator automating rolling restarts once you approve versionsThe provider, within the maintenance windows and version options you choose
Who takes backupsYour team, using tools such as mongodump or filesystem snapshotsYour team, through operator backup resources or external tooling you configureThe provider's backup service, with retention and restore terms to confirm in writing
Who owns failoverYour team, through replica set election and monitoring you buildThe operator and your team share it; confirm how it handles member loss and node drainsThe provider, although you still confirm election behavior and connection retry settings
Network placementMembers on your private network, reachable only from Rocket.Chat hosts and admin pathsMembers inside the cluster network, with pod-to-pod traffic and storage classes you definePrivate endpoints or peering into your VPC, which you must confirm for the region and tier
Data residency and controlFull control of location, keys and hardware, including air-gapped sitesControl of location and keys through your cluster, dependent on the cluster's own controlsDepends on the provider's regions, sub-processors and key management options; confirm before scoping
Main cost driversHardware, storage, licensing if applicable, and staff time for patching and recovery drillsCluster capacity, persistent volumes, operator skills and ongoing platform supportInstance size, storage, backup retention, data transfer and support tier, as quoted by the provider
Fit for regulated environmentsSuits sites that must keep data on fixed hardware and already run database operationsSuits organizations that standardize on Kubernetes and have audited cluster controlsSuits teams that need a documented provider control set and accept a shared responsibility model
Skills your team needsLinux, MongoDB administration, backup and restore testingKubernetes, storage, operator lifecycle and MongoDB administrationCloud networking, IAM and MongoDB configuration within the provider's limits

Connection strings when several Rocket.Chat instances share one replica set

When you run more than one Rocket.Chat instance, every instance must point at the same MongoDB replica set, and the connection string is where that agreement lives. The string needs to list every member of the set and name the replica set itself. Listing all members lets a driver find the current primary after a failover, and naming the set stops a connection from quietly attaching to a different or standalone server. A string that names only one host works until that host is down for maintenance, which is the moment you most need the cluster to keep serving messages. Every instance should use an identical string so that all of them see the same primary and the same data.

Before you write the string, read the MongoDB connection options that the official Rocket.Chat system requirements and deployment documentation describe for the version you are installing, and confirm the exact option names, the expected format of the host list and any requirement on read or write concern. Do not copy a string from an older guide or a forum post, since option names and defaults change between releases. Check whether the string is supplied through an environment variable or a configuration file in your chosen deployment method, and whether any character in the password needs URL encoding. Then test the string from each instance host, not only from your workstation, because firewall rules between application hosts and database members are a common cause of intermittent failures. Record the final string in your configuration management system with the replica set name and member list, so that adding or replacing a member later is a planned change applied to every instance at once.

Set up the replica set for Rocket.Chat in order

This sequence takes an empty database tier to a three-member MongoDB 8.0 replica set that Rocket.Chat can reach through one connection string, with a tested failover before any users depend on it. Each step ends with a check so a failed stage is caught before the next one starts.

  1. Confirm the Rocket.Chat release and MongoDB version

    Start by checking which Rocket.Chat release you will run and confirm it requires MongoDB 8.0 or later on a replica set. Rocket.Chat 8.x is the line that carries this requirement, so the database version must match the application release you pin, not the reverse. Confirm the release support window against the version durability documentation, since standard releases get six months of support and LTS releases get twelve. You are done when the target Rocket.Chat version and MongoDB 8.0 build are written into the change record.

  2. Provision three members across failure domains

    Provision three MongoDB members on separate hosts, and place them so that one rack, host, or availability zone failure does not remove a majority. Ask your infrastructure team to confirm the three hosts have independent power, network, and storage paths, which is what makes the failure domain separation real. Confirm name resolution and time synchronization between the members before installing anything. You are done when all three hosts resolve each other by name and their clocks agree within your standard tolerance.

  3. Initiate the replica set

    Install MongoDB 8.0 on each member with the same version and configure each with the same replica set name. From one member, run the initiate operation with all three members listed, and assign the intended priorities if one site should preferentially hold the primary. Keep the replica set name in your configuration records because every client connection string will reference it. You are done when the initiate command returns success on the first member and the configuration lists three members.

  4. Confirm member health and primary election

    Check the replica set status and confirm one member is elected primary and the other two are secondaries in a healthy state. Look at replication lag on the secondaries and at the heartbeat status between members, since a member stuck in a recovering or unreachable state will block a clean failover later. If no primary is elected, resolve the network or hostname issue before going further. You are done when the status output shows one primary, two secondaries, and no member in an error state.

  5. Configure authentication and TLS

    Create the administrative users on the primary, enable keyfile or certificate-based internal authentication between members, and enable TLS for client and member traffic using certificates your organization issues or approves. Create a dedicated database user for Rocket.Chat with only the permissions it needs, and store its credentials in your secrets system rather than in configuration files. Ask your security team to confirm the certificate chain and rotation process. You are done when an unauthenticated connection is refused and the Rocket.Chat user can authenticate over TLS.

  6. Point Rocket.Chat at the set

    Set the Rocket.Chat database connection string to list all three members and the replica set name, and include the TLS and authentication options your configuration requires. Listing every member lets the driver find the new primary after an election without manual changes. Apply the setting on every Rocket.Chat instance so they all reach the same set. You are done when each Rocket.Chat instance starts cleanly, completes its database connection, and shows no errors in its logs.

  7. Verify failover with a test before go-live

    Stop the current primary in a controlled window and confirm that a secondary is elected and Rocket.Chat keeps serving messages with, at most, a brief interruption. Then restart the stopped member, confirm it rejoins as a secondary, and check replication lag returns to normal. Record the observed election time and any user-visible errors so you can compare them with your availability expectations. You are done when the test passes, the results are documented, and the team has agreed to go live.

Where replica set backups should live

A replica set protects against a failed member, not against a bad deployment, a deleted collection or a failed site. The cards below cover where the database backup should sit, what else needs its own copy, and when a restore has to be proven before the next upgrade.

Outside the database failure domain

A backup stored on the same hosts, storage array or cloud account as the replica set can be lost in the same incident that takes the database down. Place backup copies in a separate account, site or storage system with its own credentials, so a compromised administrator login cannot delete both the live data and its recovery copy. Ask who can delete backup objects and whether deletion is logged or protected by retention locks.

Database backup and uploads kept apart

The MongoDB backup holds messages, users, settings and room metadata. Files stored outside MongoDB, such as uploads on S3, MinIO or a file system, are not in that dump and need their own backup schedule and retention. If the database and the file store are restored to different points in time, users may see messages that point to missing attachments. Confirm where your uploads live before you set the backup scope.

System requirements

Replica set members are not backups

Three members give high availability, and a delayed or hidden member can help with some recovery cases, but both replicate the same bad writes that a mistaken delete or a corrupted update creates. Replication is not point-in-time recovery. Treat it as an availability control and keep separate, restorable backups for data recovery.

Restore tested before each upgrade

Upgrades of Rocket.Chat and its database carry the risk of a failed migration with no clean rollback. Before moving to a new Rocket.Chat line, restore the latest backup into a separate environment running the same MongoDB version, start the application against it and check logins, room history and file access. Record how long the restore took so the production window can be planned.

Backup and restore topic

The backup and restore topic covers the commands for standalone and replica set databases, restore order, and the handling of uploads kept outside MongoDB. Use it to write the runbook for this design. Keep the commands and the runbook versioned with the deployment so the team restores from the same steps it tested.

Questions buyers ask about the Rocket.Chat database design

What does a MongoDB replica set design for Rocket.Chat cost?

The cost comes from three places: the database servers or managed service instances, the storage and backup capacity behind them, and the people who design and build the cluster. Hardware or cloud spend recurs every month, while design and build work is usually one-time. The main cost drivers are the number of members, the storage size, whether you run three members in separate failure domains, and whether you choose a managed service. DeployOpen does not publish prices, so ask for a quote that lists each component, who pays for it, and which items recur. Rocket.Chat's own reference architectures set the scale tiers that influence how large the database needs to be.

How long does a Rocket.Chat database design and build take?

Duration depends on how much of the environment is already defined. A team with existing MongoDB operations, a clear network layout and agreed backup targets moves much faster than one that must decide all of these first. Time is usually spent on sizing, choosing between the operator and a managed service, configuring the three members and connection strings, testing failover, and setting up backups and restore checks. Ask for a written schedule tied to the agreed scope, and confirm which steps depend on your change approval and infrastructure lead times.

What must our internal team provide before a database engagement starts?

Your team needs to supply the target environment and its constraints. That includes the Kubernetes cluster or virtual machines where MongoDB will run, the storage classes and their performance, network rules between the Rocket.Chat instances and the database, the expected concurrent user count, and where backups may be stored. You also need to name an owner for database access, secrets and change approval. Confirm the Rocket.Chat version you plan to run, because Rocket.Chat 8.x requires MongoDB 8.0 or later as a replica set, and confirm whether you need a paid plan for multi-instance designs.

Is a single MongoDB node acceptable for Rocket.Chat?

A single node is a valid starting point for a small test or low-stakes workspace, but it does not give high availability. Rocket.Chat 8.x requires MongoDB running as a replica set, so even a single-node deployment must be configured as a replica set with one member. A three-member replica set is strongly recommended for high availability. Decide this with the business owner based on how much downtime the workspace can tolerate, and document the decision so that the move to three members is planned rather than improvised later.

Should we use the MongoDB Kubernetes operator or a managed MongoDB service?

Choose the operator when you run Kubernetes in infrastructure you control and your team can operate stateful workloads, including upgrades, storage and backup jobs. Choose a managed service when your organization already relies on a provider for database operations and that provider meets your data residency and security requirements. The operator keeps data inside your cluster but adds operational work for your team. A managed service reduces that work but moves some control to the provider. Check where data is stored, how backups are retained and restored, how failover is tested, and whether the provider's MongoDB version matches what Rocket.Chat 8.x requires.

What connection string should multiple Rocket.Chat instances use?

Every Rocket.Chat instance should point to the same replica set name and list all members, so the driver can find the primary after a failover. The Rocket.Chat configuration reads its MongoDB URL from an environment setting, and the replica set name must be included in the connection options. Confirm the exact format in the Rocket.Chat system requirements and your deployment guide before you write it, and test a failover by stopping the primary to check that the workspace keeps running. Keep the connection string in a secrets store, not in a plain compose file.

Where should MongoDB backups be placed, and who tests restores?

Store backups in a location separate from the database members, so that a failure or compromise of the cluster does not also remove the backups. Retention, encryption and access rules should follow your organization's records and recovery requirements. Restores must be tested, not assumed, and a restore test should run before any Rocket.Chat upgrade. Your team should own the backup targets and approval of retention rules, while the design partner can document the procedure. Ask for the backup and restore steps to be written as a runbook and rehearsed on a non-production copy.

How Rocket.Chat instances connect to the replica set

Traffic enters through a load balancer and reaches several Rocket.Chat instances, which all share one MongoDB replica set with three members. The application tier sits in its own trust boundary, and the database members talk only to each other and to the instances. Backups leave the replica set through a separate path into a different failure domain. Check that every instance uses the same replica set name in its connection string, that writes go to the primary, and that a restore has been tested from the separate backup location.

Load-balanced Rocket.Chat instances use one replica set, with backups kept in a separate failure domain.

How DeployOpen scopes and delivers Rocket.Chat database design

DeployOpen plans, builds, tests and documents the MongoDB replica set under your Rocket.Chat deployment inside your own infrastructure. The work starts from a written scope, so the database design, connection settings and backup placement are agreed before anything is built.

How we scope

  • Confirm the Rocket.Chat version line and the MongoDB 8.0 or later target before any design work begins.
  • Record the expected concurrent users, number of Rocket.Chat instances and planned paid-plan tier in the written scope.
  • Agree where each of the three replica set members runs, and which failure domains they must not share.

How we build

  • Deploy the three-member replica set on infrastructure you control, using the operator or managed option agreed in scope.
  • Configure the connection string so every Rocket.Chat instance connects to the same replica set name and member list.
  • Test primary failover in a staging workspace and record how Rocket.Chat behaves during the election window.

How we hand over

  • Deliver a design document covering topology, member placement, connection strings, authentication and backup location.
  • Provide a restore test record showing the backup placement and restore order were exercised before go-live.
  • Walk your platform and database teams through runbooks for member replacement, failover checks and version upgrades.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing of the database layer are available as a retainer.
  • Ask your DeployOpen contact to confirm the quote follows from the written scope, since no price list is published.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.