MongoDB Auto-Clustering

MongoDB Auto-Clustering

MongoDB Auto-Clustering automatically creates a reliable replica set and provides redundancy, data high availability, automatic node discovery during scaling, and automated failover.

MongoDB Auto-Clustering Benefits

Redundancy & high availabilityMultiple copies of the same data are stored on different MongoDB servers for increased fault tolerance.
Scalability & autodiscoveryNodes added during horizontal scaling are discovered and joined to the cluster automatically.
Automated failoverUnavailable or high-latency nodes are temporarily excluded and re-added when connectivity is restored.
MongoDB Replica Set
MongoDB replica set with Primary and Secondary members.

MongoDB Auto-Clustering Specifics

A replica set contains at least three MongoDB instances that maintain the same data. One node is the Primary and handles all writes. Changes are recorded in the oplog and replicated to the Secondary members. If the Primary becomes unavailable, another active member is elected automatically.

chainingAllowed: trueAllows Secondary members to replicate from other Secondaries.
heartbeatIntervalMillis: 2000Heartbeat frequency in milliseconds.
heartbeatTimeoutSecs: 10Time before a member with no successful heartbeat is considered inaccessible.
electionTimeoutMillis: 10000Timeout used to detect an unreachable Primary.
catchUpTimeoutMillis: -1Allows unlimited catch-up time for a newly elected Primary.
catchUpTakeoverDelayMillis: 30000Delay before a more up-to-date Secondary initiates an election takeover.

These values can be reconfigured after installation with rs.reconfig().

Authentication and Storage

The platform automatically configures replica-set authentication in /etc/mongod.conf and creates the authentication key at /home/jelastic/mongodb.key. The key is added to redeploy.conf so it survives container lifecycle operations.

MongoDB uses WiredTiger by default. The documented internal-cache size is 50% of total RAM minus 1 GB, with a minimum of 256 MB. New nodes are added automatically during scale-out and removed automatically during scale-in.

Create a MongoDB Cluster

  1. Open New Environment, choose MongoDB, and enable Auto-Clustering.
  2. Configure resources, public IPs, region, and other required parameters.
  3. Click Create and wait while the platform configures the replica set.
  4. After installation, check the email containing replica-set credentials.
MongoDB auto-clustering
Enable Auto-Clustering in the MongoDB topology.
Recommended topology: the source recommends 4 GiB RAM (32 cloudlets) for proper replica-set operation, and the minimum MongoDB auto-cluster size is 3 nodes.
MongoDB scaling
Recommended dynamic scaling limit for MongoDB nodes.
MongoDB cluster
The automatically configured MongoDB cluster.
MongoDB credentials email
Replica-set credentials are sent after installation.

Application Connection Strings

Because a Secondary can become Primary after failover or restart, an application should not depend on one fixed Primary hostname. The source recommends including all member hostnames, the replica-set name, and a suitable read preference.

client = new MongoClient(
  "mongodb://admin:cbfef7418d@node540102-mongo-cluster.madrid.jele.io:27017,node540096-mongo-cluster.madrid.jele.io:27017,node540099-mongo-cluster.madrid.jele.io:27017/admin",
  {
    useUnifiedTopology: true,
    readPreference: 'primaryPreferred',
    replicaSet: 'rs0'
  }
);
useUnifiedTopology: trueUses MongoDB’s newer server discovery and monitoring engine.
primaryPreferredReads from the Primary when available and from Secondaries if the Primary is unavailable.
replicaSet: rs0The default replica-set name used by the platform.

External Connection through Endpoint

For an external application connection through the Shared Load Balancer, maintain a connection to the Primary through an endpoint. For this case, the source removes the replicaSet parameter.

MongoDB endpoint
External access to the Primary through an endpoint.
client = new MongoClient(
  "mongodb://admin:bfef7418d@node540102-mongo-cluster.madrid.jele.io:11013/admin",
  { useUnifiedTopology: true }
);

Administration and SSH Access

The auto-cluster uses Mongo Express as the administration panel, which supports MongoDB replica sets.

Mongo Express admin panel
Mongo Express administration panel for the replica set.

You can also connect through Web SSH:

mongosh -u {user} -p {password} {DB_name}
Older versions: use mongo for MongoDB 3.x/4.x and mongosh for MongoDB 6.x/7.x, with the same parameters.
MongoDB SSH connection
Connect to the MongoDB replica set from Web SSH.

Check Replica Set Status

Run the following command:

rs.status()
MongoDB replica status
Verify that the rs0 replica set is running.

Use rs.conf() if you need to inspect the replica-set configuration.

Expected Result

A MongoDB replica set with at least three members is created automatically, with Primary election, Secondary replication, automatic scaling integration, internal authentication, and failover handling configured by the platform.

Important Notes

  • The minimum MongoDB auto-cluster size is 3 nodes.
  • The source recommends 4 GiB RAM (32 cloudlets) per replica-set node.
  • The default replica-set name is rs0.
  • The internal authentication key is stored at /home/jelastic/mongodb.key.
  • Horizontal scaling automatically adds or removes replica-set members.
  • Applications within one hosting platform should include all members and the replica-set name in their connection string.
  • Use rs.status() to check cluster state and rs.conf() to inspect configuration.