02 / 15

Discuss Vertical and Horizontal scaling?

Difficulty: 7/10
sharding, replication, capacity planning
  1. 1

    Vertical Scaling involves increasing the capacity of a single server, such as using a more powerful CPU, adding more RAM, or increasing the amount of storage space. Limitations in available technology may restrict a single machine from being sufficiently powerful for a given workload. Additionally, Cloud-based providers have hard ceilings based on available hardware configurations. As a result, there is a practical maximum for vertical scaling.

  2. 2

    Horizontal Scaling involves dividing the system dataset and load over multiple servers, adding additional servers to increase capacity as required. While the overall speed or capacity of a single machine may not be high, each machine handles a subset of the overall workload, potentially providing better efficiency than a single high-speed high-capacity server. Expanding the capacity of the deployment only requires adding additional servers as needed, which can be a lower overall cost than high-end hardware for a single machine. The trade off is increased complexity in infrastructure and maintenance for the deployment.

Scenario Questions

0-2 years experience

  1. 1If our MongoDB deployment is hitting CPU limits on the primary, what steps would you take to scale it vertically, and what are the immediate effects on read/write performance?
  2. 2Suppose we add a second replica set member to our existing single-node MongoDB. How does that change the way reads are served, and what does it mean for scaling horizontally?

2-5 years experience

  1. 1Our e‑commerce service experienced a sudden spike in traffic and the MongoDB cluster started showing increased latency. We tried adding more shards, but the latency didn't improve. Walk me through how you would diagnose whether we need more horizontal scaling versus vertical scaling.
  2. 2We have a sharded MongoDB cluster with three shards, each on a 4‑core machine. The ops team wants to reduce costs by moving to smaller instances. What trade‑offs should you consider between shrinking vertically and adding more shards horizontally?

5-8 years experience

  1. 1Design a scaling strategy for a time‑series logging system that writes millions of documents per second to MongoDB. Explain how you would combine vertical scaling of config servers with horizontal sharding of data, and how you’d handle rebalancing without downtime.
  2. 2Our global application uses MongoDB with a primary in US‑East and read replicas in EU. We need to support a 10× increase in write volume. Discuss the architectural changes you’d make, focusing on vertical vs horizontal scaling, and the impact on consistency and failover.

8+ years experience

  1. 1The company plans to migrate a legacy monolithic MongoDB deployment to a multi‑region, horizontally sharded architecture while also upgrading hardware for vertical scaling. Outline the long‑term roadmap, cross‑team coordination, and how you’d mitigate risks of data migration and operational complexity.
  2. 2Leadership is debating whether to invest in larger, more powerful servers for our MongoDB cluster or to fund additional shards across cheaper machines. As a principal engineer, how would you evaluate the total cost of ownership, operational overhead, and future scalability to advise the decision?

Follow-up Questions

  • What monitoring metrics would you watch to know when vertical scaling is no longer sufficient?
  • How does MongoDB’s balancer affect performance during horizontal scaling?
  • Can you describe a scenario where vertical scaling could actually degrade performance?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.