Scale Cube
Learning Objectives
- You know of scale cube and its three dimensions.
- You know of monolithic, microservices, and event-driven architectural patterns.
Horizontal and vertical scalability highlight classic strategies for scaling software: increasing the resources of an existing server (vertical scaling) or adding more servers (horizontal scaling). Similarly, the architectural patterns of monolithic, microservices, and event-driven architectures provide different ways to structure an application. None of these discuss, howewer, what to scale and how to scale it.
The Scale Cube is a framework that guides system scaling across three dimensions:
- Replication
- Functional Decomposition
- Data Partitioning
Combining these dimensions can enhance scalability by addressing different aspects of system architecture.
For a detailed exploration of the Scale Cube, refer to The Art of Scalability by Martin L. Abbott and Michael T. Fisher.
Replication
Replication involves duplicating services and data across multiple servers or instances, in line with horizontal scaling discussed earlier.
The key strategies of replication include service duplication (using load balancers to distribute traffic), data cloning (implementing read replicas), and redundancy (maintaining multiple data copies). In replication, the focus is on increasing capacity by adding more machines rather than enhancing the power of individual machines. Replication may also include redundancy with active and passive replicas, where active replicas handle incoming requests, while passive replicas wait to take over in case of failure.
Replication brings advantages such as improved availability, enhanced scalability, and simpler implementation. However, it also presents challenges such as consistency management, resource utilization, and load balancing and synchronization.
Functional Decomposition
Functional Decomposition breaks a system into smaller, manageable services, each handling specific functionalities. Functional decomposition can be seen as a bridge from monolithic architecture to microservices architecture.
The key strategies of functional decomposition include service segmentation (using Domain-Driven Design to organize services), bounded contexts (defining explicit boundaries such as APIs for each service), independent scaling (scaling each service based on its unique load and performance needs), and autonomous development (enabling teams to develop, deploy, and manage services independently).
Functional decomposition enhances maintainability, flexibility, and resilience, but it also introduces challenges such as increased complexity, data management, and operational overhead.
Data partitioning
Data Partitioning divides the application data (e.g. database) into smaller, manageable segments called shards, each handling a subset of the data. A shard could, for example, contain data for a specific customer or geographic region, or be dedicated to a specific service.
The key strategies of data partitioning include customer-based partitioning (distributing data based on customer IDs), geographical sharding (partitioning data by geographic regions), service-specific shards (assigning data subsets to particular services), and range and hash-based sharding (utilizing range-based or hash-based methods for data distribution).
Data partitioning improves scalability by distributing data load across multiple shards, enhances performance by reducing shard sizes, and improves fault isolation by containing failures within individual shards. However, data partitioning also introduces challenges such as complex queries, data rebalancing, and consistency management.
The dimensions of scale cube align well with the architectural patterns that we discussed earlier. For example, replication aligns with horizontal scaling and microservices architecture, functional decomposition aligns with microservices architecture, and data partitioning aligns with event-driven architecture and microservices architecture.