AI News Feed
Market watch
Companies

Meta Open-Sources Rebalancer, the C++ Solver Behind About 40 Million Daily Placement Problems

Meta has released Rebalancer, a C++ library with a Python interface for assignment problems, under Apache 2.0. The company says it has handled resource allocation at Meta for more than nine years and solves roughly 40 million problems a day.

The release is published under Apache 2.0 and ships with documentation, a PyPI package and a debugging interface called Rebalancer Explorer, according to a MarkTechPost report citing Meta's engineering blog. The command pip install rebalancer installs version 1.0.4 for Python 3.12 and later, with prebuilt wheels for Linux x86-64 and macOS 14 or later on ARM64; .deb, .rpm and Homebrew packages are also available. PyPI still classifies the project as Alpha.

Meta describes assignment problems running throughout its stack: racks into datacenters, servers to services, tasks to servers and user traffic to datacenters. It names two blockers, usability and scalability. Engineers struggle to turn policies into precise formulas, and many of the problems are NP-hard and too large for commercial solvers, the company said. Rebalancer's answer is to separate how a problem is specified from how it is solved, a design detailed in an OSDI 2024 paper, "Optimizing Resource Allocation in Hyperscale Datacenters."

The specification language has three layers. Modeling constructs cover dimensions such as CPU or storage, partitions as groups of objects, scopes as groups of bins, and utilization. An expression API aggregates utilization with SUM or MAX, or transforms it with operations such as SQUARE. A spec API offers dozens of predefined objectives and constraints. In Meta's example, tasks are objects, servers are bins and racks are a scope: a CapacitySpec caps CPU and storage per server, a GroupCountSpec keeps one job type per rack, and a BalanceSpec balances each server's utilization across both dimensions.

Rebalancer compiles the spec into a directed acyclic expression graph, with leaf nodes holding utilization values and aggregation and transformation nodes above them. Users supply an initial assignment and a stopping condition, and constraints that the initial assignment already violates become high-priority goals.

Two solvers work from that graph. The optimal solver translates it into a mixed integer program for FICO Xpress, Gurobi or HiGHS, relying on variable aggregation and symmetry breaking to shrink models; the worst-case model size remains O(objects × bins), and Meta says its largest problems are too big for any MIP solver. The local search solver works directly on the expression graph, exploring moves of objects to other bins with a worst-case neighborhood of O(objects + bins) and then applying the best candidate that breaks no constraint. Evaluation is parallelized, reaching millions of evaluations per second, and the search space is pruned. Meta uses local search for almost all large problems and MIP for small to mid-size ones, often prototyping with MIP first.

In production, Meta reports about 40 million assignment problems solved per day across more than 30 unique formulations. P99 solve time is 12 seconds on 265,000 objects and 3,200 bins. Problems above 1 million objects and 5,000 bins average 171 seconds across more than 3,400 runs.

Meta lists three use cases for the library. One is placing shards, tasks or containers on a cluster, assigning work to servers under CPU and memory caps while spreading replicas across racks; Meta's Shard Manager and RAS run this pattern. Another is balancing traffic and workloads across regions, trading latency against load, which Taiji does for edge traffic and which Meta also applies to balancing ML training by priority. The third is operational assignment outside infrastructure, such as mapping support tickets to engineers, meetings to rooms or desks to people under capacity rules. Meta says it has done all three.

Modelers at Meta spent most of their time debugging solver behavior, so the release includes Rebalancer Explorer, a Dockerized web UI that shows binding constraints, relaxation effects and why an object landed in a bin.

Editor's Summary

Meta has open-sourced Rebalancer under Apache 2.0, offering a C++ solver with a Python interface for assignment problems that it says runs about 40 million times a day internally. The design splits problem specification from solving, pairing a mixed integer program path for smaller cases with a local search path for problems too large for commercial solvers. The release also includes documentation, packaged installs and a debugging UI, making a long-internal tool available to outside developers.