Scalability

What is scalability?

Scalability means your system can handle increased loads, such as more users, data, or traffic, without a proportional drop in performance. It describes how well a system grows under load.

  • Vertical scaling (scale-up): Adding more resources to a single machine (more CPU, RAM). It’s simpler but limited by hardware constraints.
  • Horizontal scaling (scale-out): Adding more machines or instances to increase capacity. It’s harder to manage but offers near-infinite growth potential.

In modern architectures, horizontal scaling is the standard approach, powering distributed databases, microservices, and load-balanced systems worldwide. This approach enables elasticity, allowing resources to be added or removed dynamically based on real-time demand.

image

Vertical Scaling (scaling up)

Upgrading the CPU, RAM, Storage, or other hardware components to boost the server's capacity.

image
  • Upgrading CPU: Replacing your server's processor with a more powerful one.
  • Increasing RAM: Adding more memory to handle larger datasets and reduce reliance on slower storage.
  • Enhancing Storage: Switching to faster storage (like SSDs) or increasing overall storage capacity.

Pros of Vertical Scaling

  1. Simplicity: Vertical scaling is relatively simple to implement as it doesn't require changes to the application architecture.
  2. Lower latency: Since all the resources are located on a single machine, vertical scaling can eliminate the need for inter-server communication thus lowering the latency.
  3. Reduced software costs: In the initial phase, vertical scaling may be more cost-effective than horizontal scaling, especially when dealing with moderate increases in demand.
  4. No Major Code Changes: Often requires little to no adjustments to your application's codebase.

Cons of Vertical Scaling

  1. Limited scalability: There is a limit to how much a single machine can be upgraded.
  2. Single point of failure: With all resources on one server, any hardware failure can bring down the entire system.
  3. Downtime: Upgrading hardware often requires taking the server offline, which can be a significant disadvantage.
  4. Higher Costs in the Long Run: High-end servers with powerful CPUs and large amounts of RAM can get very expensive as you scale.

Horizontal Scaling (scaling out)

Adding more servers or nodes to the system to distribute the load across multiple machines. Each server runs a copy of the application, and the load is balanced among them often using a load balancer.

image

Pros of horizontal scaling

  1. Near-Limitless Scalability: You can continue to add nodes as long as your architecture supports it, providing the ability to handle larger loads.
  2. Improved fault tolerance: The failure of one node does not bring down the entire system, minimizing downtime.
  3. Cost-effective: Horizontal scaling can be more cost-effective as it uses commodity hardware instead of expensive high-end servers.

Cons of horizontal scaling

  1. Complexity: Distributing the application across multiple servers introduces complexity in terms of data consistency, load balancing, and inter-server communication.
  2. Increased latency: Communication between servers can introduce additional latency compared to a single machine.
  3. Cost: Initial setup and maintenance costs can be higher due to the complexity of the infrastructure.
  4. Application Compatibility: Your application's code might need adjustments to work effectively in a distributed environment.

When to choose vertical scaling

Vertical scaling is a good fit in the following scenarios:

  1. Limited Scalability: Small to medium-sized applications with a limited growth forecast and your needs are easily met by hardware upgrades.
  2. Legacy applications: When there is a tight coupling between components, making it difficult to distribute across multiple servers.
  3. Low Latency: When low latency is a critical requirement, and inter-server communication overhead is unacceptable.
  4. Cost-sensitive projects: When the budget does not allow for a complex infrastructure and the cost of scaling horizontally outweighs the benefits, such as in the case of expensive software licenses.

When to choose horizontal scaling

Horizontal scaling is a good fit in the following situations:

  1. Rapid Growth: When experiencing rapid growth and requiring the ability to handle increasing traffic.
  2. High availability needs: When the application needs to be highly available and resilient to node failures.
  3. Easily Distributable: When the application can be easily distributed across multiple servers without significant modifications.
  4. Microservices architectures: When applications are designed around microservices, which naturally lend themselves to horizontal scaling.
  5. Cost Effectiveness: When cost-effectiveness is a priority, and the use of commodity hardware is preferred.

Combining both

A system can initially scale vertically until it reaches the practical limits of a single machine, and then switch to horizontal scaling to accommodate further growth.

Databases can use sharding and replication.

Resources

SuperMade with Super