Abstract
Modern cluster management systems often rely on complex, hard-coded heuristics that struggle with the NP-hard nature of resource allocation. Weave is a declarative framework that replaces these ad-hoc "greedy" algorithms with SQL queries. By compiling SQL policies into optimization models, Weave simplifies system maintenance while significantly improving placement quality and convergence times. This paper details the architecture of Weave, its use of relational state, and its performance across production-grade scenarios.
Introduction
Cluster management systems like Kubernetes and OpenStack face the daunting task of placing containers or virtual machines across nodes while satisfying numerous hard constraints (e.g., resource requirements) and soft preferences (e.g., load balancing). Traditionally, developers have addressed this by writing custom heuristics. However, this approach has reached a "software engineering dead end" characterized by extreme code complexity, suboptimality in tight clusters, and a lack of separation between system state and logic.
As shown in Figure 2, greedy one-at-a-time placement often fails to find feasible solutions in constrained environments where a global view is required. Weave addresses these issues by treating cluster management as a database problem, allowing for more robust and maintainable scheduling logic.
System Architecture and Methods
The core of Weave is its ability to translate declarative SQL policies into optimization models. The system consists of several key components:
- Relational State: Cluster state is maintained in a standard relational database (e.g., Apache Derby).
- Declarative SQL Policies: Instead of writing complex Go or C++ algorithms, developers express constraints as SQL views with annotations like
@hard_constraintand@soft_constraint. - The Weave Compiler: This component translates SQL queries into MiniZinc optimization models. It employs sophisticated compiler optimizations, such as rewriting queries to use "global constraints" (like
all_different), which allow solvers to prune the search space much faster. - Runtime Execution: Upon state changes, Weave populates the model, invokes an off-the-shelf solver (e.g., Google OR-Tools), and updates the cluster state via database updates.
Figure 1 illustrates the workflow: the Weave Compiler processes schema and constraints into an optimization model, which the Weave Runtime then uses to interact with the solver and the cluster state database.
Key Insights
Weave's primary innovation is using SQL as a modeling language. If a developer can write a query to identify policy violations, Weave can invert that logic to find a valid configuration. This separation of concerns allows developers to focus on "what" the policy is, rather than "how" to solve it. Furthermore, when a solution is impossible, Weave can provide "unsatisfiable cores"—specific conflicting constraints—to help developers debug their policies directly in the context of their SQL code.
Evaluation and Results
Weave was evaluated against production-grade scenarios, including the Kubernetes scheduler and real-world VMware DRS traces.
- Simplicity: Complex Kubernetes policies that previously required thousands of lines of Go code were implemented in under 20 lines of SQL.
- Placement Quality: In tests where the default Kubernetes scheduler failed to place pods in 32 out of 35 runs, Weave achieved 100% placement success in 29 of those runs.
- Performance: Weave converged on solutions for high-priority pods 2x faster than baselines by efficiently handling cross-node preemption. In VM load-balancing tasks, it reduced memory utilization variance from a 39–85% range to a much tighter 51–63% range.
Conclusion
Weave demonstrates that declarative programming and modern optimization solvers can effectively replace brittle heuristics in cluster management. While challenges remain regarding "flattening" latency and extreme scale, Weave offers a path toward more maintainable and efficient cloud infrastructure by decoupling policy from execution logic.
Summary updated