Which Snowflake warehouse has room for the next query?
Argmax and Yuki used linear programming to estimate how much capacity a query needs. A production comparison measured the tradeoff between shorter queues and compute cost.
Two queries can fill a warehouse very differently
When a query arrives, Yuki’s proxy chooses a Snowflake warehouse to run it. Sending the query to an active warehouse can save credits. If that warehouse is already busy, the same choice can leave the user waiting while another warehouse has capacity.
Yuki’s baseline gave every query one eighth of a warehouse. In that model, a heavy query and a light one together use only a quarter of the available capacity. But if the heavy query needs the whole warehouse, the light one will queue. Argmax and Yuki wanted to estimate that difference before routing the next request.
Learn from queries that ran together
A query’s runtime alone doesn’t reveal how much parallel compute it needs. The team instead sampled groups of queries that were executing together, excluding time spent compiling or waiting. Each group offered a clue: the queries in it had all fit at the same time.
The team modeled warehouse capacity as eight units. In a snapshot with eight concurrent queries, each must take one unit under that assumption. If six of those queries appear in another snapshot alongside a seventh, that seventh query can take at most two. Repeated overlaps constrain the estimate for each query.
Using the HiGHS linear programming solver, the team found the largest frequency-weighted allocation consistent with those observations. Yuki could then route familiar queries using their estimated share of capacity. Previously unseen queries kept the one-unit default.
What changed in production
For one Yuki customer, the baseline and the new routing policy each ran for a week, in separate periods with similar query counts. Compared with baseline, the share of queries queued for more than 500 milliseconds fell 14.32%. Average time spent waiting because of warehouse overload fell 22.88%. The largest relative change was in the long waits: the share queued for more than 20 seconds fell 39.14%.
The new policy sent more work to idle warehouses, and credits per query rose 5.62%. For this customer, the routing decision therefore had a measurable price. A team choosing its own policy can weigh the cost of activating more capacity against the value of getting users out of long queues.