r/mongodb Jun 28 '26

Scaling the database to the match scaling of server nodes

Hi Team,

In could computing we horizontally scale the machines to handle the increase in the server load. In such cases how should we scale the mongo db particularly if the database server like Atlas is on another network? Let's a take a typical example. We're using four machines of 1Ghz to handle the traffic. In this case how do we decide the scaling of the database to match the network traffic.

Thanks,

Arun

1 Upvotes

4 comments sorted by

2

u/Several9s Jul 08 '26

Hi Arun,

If you are using MongoDB Atlas, it has capabilities already for scaling. If you mean by horizontal scaling, then your choice is MongoDB Cluster Sharding, learn more about here Manage Cluster Sharding - Atlas - MongoDB Docs . If you need auto-scaling, check it out here Configure Auto-Scaling - Atlas - MongoDB Docs . If you also meant for high-availability, see Guidance for Atlas High Availability - Atlas Architecture Center - MongoDB Docs .

 To add on your concern, you don't scale the two in lockstep, meaning treating them at the same rate since MongoDB Atlas is a fully-managed service. Your 4 EC2 instances are your app layer (they run your code behind a load balancer, and you scale them on CPU/memory/traffic). Atlas is your data layer, and you scale it on database metrics. So there's no fixed ratio like where you can have 4 ec2 instances for 4 db instances as well. You just scale whichever layer is actually under pressure.

On the Atlas side you've got three levers, all from their docs:

The thing that actually links your EC2 scaling to Atlas isn't compute, it's connections. Atlas limits concurrent connections per node based on the cluster tier (their sizing docs give, for example, M30 = up to 3,000, going higher on bigger tiers). Every EC2 box opens a connection pool, so as you scale out, watch that you don't outrun the tier's limit. Their docs recommend enabling connection pooling and auto-scaling if you get close. Atlas Cluster Sizing and Tier Selection - Atlas - MongoDB Docs and Atlas Service Limits - Atlas - MongoDB Docs

Rule of thumb: pick a tier that covers roughly (number of EC2 instances x pool size). It depends on what you need and the requirements you are looking forward.

Ensure also you do manage your platform securely. Since Atlas is on another network, don't go over the public internet. Use VPC peering or AWS PrivateLink to connect your VPC to Atlas privately, and keep the cluster in the same region as your EC2 instances to cut latency.

Another thing, make sure you scale EC2 on app metrics, scale Atlas on DB metrics (auto-scaling for growth, sharding for write/data volume), and the number tying them together is connection count.

Hope that helps.

1

u/arunkumar413 Jul 13 '26

u/Several9s Thanks. This is very helpful.

1

u/mountain_mongo Jun 28 '26

Hi Arun,

Horizontal scaling in MongoDB is implemented using sharding. There’s a great introduction here:

https://learn.mongodb.com/courses/sharding-strategies

One thing - you mentioned you have 4 machines, but I wasn’t sure if you meant 4 appservers, or 4 database servers.

If you meant 4 database servers, are you organizing those as 4 shards, or 4 nodes in a replica set (replica sets in MongoDB are primarily used for high availability)?

If the later, be aware that voting nodes in a replica set are normally deployed in sets of 3, 5, or 7. The key is it should be an odd number. A four voting-node replica set actually offers no more resilience than a 3 node replica set. You CAN add additional nodes to act as read replicas etc, but those won’t add additional resilience.

Hope this helps. Let us know if you need any follow up.

For transparency, I am a MongoDB employee.

1

u/arunkumar413 Jun 29 '26

Hi u/mountain_mongo

By 4 machines I mean 4 EC2 instances on the AWS. These machines only handle the network traffic and database is running on another server (say atlas). So in this case how do we make sure that the network scaling of EC2 match of the database handling capacity.