Meta's Rebalancer is an open-source library designed to solve large-scale resource assignment problems across various infrastructure layers. It addresses challenges in usability and scalability by separating problem specification from solution, offering both optimal (MIP-based) and highly optimized local search solvers. This tool has been critical for managing resource allocation for tasks, services, and hardware within Meta's hyperscale datacenters for nearly a decade.
Read original on Meta EngineeringThe Rebalancer library from Meta provides a generic, high-performance solution for assignment problems, which are pervasive in large-scale distributed systems. These problems involve assigning "objects" to "bins" while optimizing objectives and adhering to constraints. Examples include placing servers in racks, tasks on servers, or routing traffic to datacenters. The core challenge is translating real-world policies into mathematical models and solving NP-hard problems efficiently.
Rebalancer tackles usability by offering a high-level language for problem specification using constructs like dimensions, partitions, scopes, and utilization. This abstraction simplifies the process of defining complex constraints and objectives, making it accessible to practitioners without deep optimization expertise. The library provides an API with dozens of predefined "specs" (recipes) for common objectives and constraints, which can be combined to model intricate scenarios.
Once a problem is specified, Rebalancer translates it into an expression graph. It offers two primary solving techniques:
When to Choose Which Solver
For small to mid-sized problems with moderate solve time requirements, the optimal solver can provide exact solutions. For large-scale problems, especially those in production environments like Meta's, the local search solver is preferred due to its superior scalability and speed, even if it yields near-optimal solutions. It's also common to prototype with optimal solvers and then migrate to local search after establishing a baseline solution.
To aid in debugging the solver's behavior, Rebalancer includes a specialized UI tool called Rebalancer Explorer. This Dockerized web UI helps modelers understand which constraints are binding, explore the impact of relaxing constraints, and analyze why specific assignments were made, significantly reducing debugging time and effort.