Operating Shared Trino Workloads with Fleet Commander

Ram AggarwalData Platforms Engineer
Query traffic routed to Trino fleets

When unrelated workloads share a cluster, they compete for finite resources. A poorly written query can consume enough memory or execution capacity to delay a dashboard, even while the cluster continues to accept new queries.

Our original setup separated workloads across three Trino clusters, which provided some isolation, but workloads were still tied to fixed destinations. This limited our ability to adapt routing decisions to changing workload demands and cluster conditions.

We needed routing decisions to account for both the policy behind each query and the capacity available at that moment. This also exposed a broader reliability challenge: query routing and cluster management cannot be treated as entirely separate problems.

Why Three Clusters Were Not Enough

We had split the workload across three Trino clusters. Primary handled BI and interactive reporting. Secondary took care of scheduled and ad-hoc queries, while ETL ran the jobs behind our data models.

That helped, but it didn't stop queries from getting in each other's way. A poorly written query on the Primary cluster could consume memory or hold execution slots for too long. Other BI queries would then have to wait, even if the Secondary or ETL cluster had room to take on more work. That spare capacity was of little help because queries were still tied to their assigned clusters.

The fixed assignments also meant that a change in one cluster often involved work elsewhere in the setup. Even a scaling change meant revisiting its configuration and Gateway registration. When something went wrong with a query, investigating it added another layer of work.

From Fixed Destinations to Routing Policy

The next step was to move beyond fixed cluster assignments and let operators define how workloads should be handled. Some queries needed isolation from other workloads. Others needed to be blocked, redirected or run with specific session properties.

It called for a way to express routing decisions through fleets rather than manage each cluster as a fixed destination. A fleet is a managed group of Trino clusters that can serve a workload, while an individual cluster is a specific deployment within that group.

Trino Fleet Commander was built to manage this process. It works alongside Trino Gateway, which remains the entry point for incoming queries. Gateway forwards the routing request to Fleet Commander, which evaluates the applicable policies and helps determine where the query should go.

Trino Gateway already provided a stable query entry point, and native resource groups controlled concurrency inside each cluster. What was missing was the coordination between query policy, placement across clusters, and capacity changes. Fleet Commander supplies that coordination while Gateway continues proxying SQL requests and results.

Query traffic and fleet management
Enlarge diagramClose enlarged diagram
Query traffic and fleet management

Keeping the Routing Path Focused

A routing request needs enough context to determine where a query should go. Fleet Commander receives information from Trino Gateway, including user identity, SQL text, schemas, tables, client tags and supported client metadata. Its routing engine evaluates rules in priority order, with the first matching rule determining the action.

A rule can direct a query to a fleet, block it or apply specific session properties. Operators can also use Fleet Commander's test endpoint to inspect a decision trace, which shows which rule matched and why.

A Query That Fails Quickly Can Still Be Expensive

Identity tells us who submitted a query, but not whether it belongs on interactive capacity. Fleet Commander estimates complexity from Metabase card history or similar SQL, with structural heuristics for unfamiliar queries. Routing rules can use that estimate to distinguish lighter work from expensive queries.

Historical classification needs enough useful observations to be trustworthy. Similar query shapes can share history, while unfamiliar SQL receives a heuristic estimate. Neither approach guarantees how long the next execution will take.

The difficult part was deciding which executions counted as evidence. A query that fails immediately during planning should not look cheap simply because it returned quickly. Fleet Commander distinguishes those errors from executions that actually consume resources, and treats frequently failing histories conservatively.

Queries that recently hit hard limits on BI capacity can also be kept away from the fast path. These safeguards help protect interactive work; they do not optimise the SQL itself.

Choosing a Cluster That Can Actually Serve the Query

Once a routing rule identifies the target fleet, Fleet Commander checks whether it has registered, healthy capacity. If no healthy cluster is available, the router can use a configured fallback route while the control plane restores capacity. Those lifecycle actions happen asynchronously, so routing treats cluster state as a signal that can lag reality.

With load-aware routing enabled, Fleet Commander excludes draining clusters and considers current load, worker capacity, backlog, and the freshness of its observations. Old metrics receive a penalty in normal scoring, but degraded and fallback paths still make availability trade-offs. A stale observation is not a universal admission barrier.

This separates two decisions: which fleet should handle a query, and which cluster within that fleet is eligible to run it. The distinction lets routing policies express workload requirements without assuming that every cluster is ready to accept work at any given moment.

Routing policy and cluster selection
Enlarge diagramClose enlarged diagram
Routing policy and cluster selection

When Every Request Sees the Same Idle Cluster

Collected metrics lag behind new assignments. During a burst, several requests can see the same apparently idle cluster and choose it independently, creating a hotspot before the next metrics refresh.

Imagine 20 requests arriving together. If all of them choose cluster A from the same snapshot, each individual choice looks reasonable, but their combined effect creates the queue they were trying to avoid.

Fleet Commander accounts for newly assigned work as part of cluster selection. Choosing a destination and recording the assignment happen together, so later decisions can see work that has just been placed. Weighted choice among the best candidates also reduces herding.

Pending assignments are a short-lived estimate that bridges the gap between metric updates. They are not an exact ledger of running queries. Routing can continue through a degraded path when shared coordination is unavailable, but it loses the same protection against simultaneous assignments across replicas.

How pending assignments spread a burst of queries
Enlarge diagramClose enlarged diagram
How pending assignments spread a burst of queries

Figure 2. New assignments influence later placement decisions before the next metrics refresh. The burst is illustrative, not a production benchmark.

Isolation Also Has to Work Inside a Cluster

Choosing a BI fleet does not stop one BI user from monopolising it. Fleet Commander passes user identity through to Trino resource groups, enabling per-user limits alongside workload-level concurrency controls.

This gives the two layers different jobs. Routing selects the fleet and cluster that should receive the query. Trino resource groups determine how that query competes with other work inside the selected cluster. Fleet routing cannot replace admission controls, memory limits, or query tuning.

What Happens While Capacity Is Waking Up

When a fleet has no registered capacity, a configured fallback can serve queries while the control plane attempts to restore capacity. A new cluster enters service after its coordinator passes a serving-health check; a running Kubernetes pod alone is not enough.

Fallback works only if its destination has headroom and permits the workload. It temporarily relaxes the intended placement, so operators must choose it with isolation requirements in mind. Routing observations can also lag behind lifecycle changes.

Fallback while a fleet is restoring
Enlarge diagramClose enlarged diagram
Fallback while a fleet is restoring

What Changes for Operators

Fleet-based routing lets operators express workload requirements without tying every workload to a permanent cluster. Policies decide where work belongs, while cluster selection considers current load and availability.

Decision traces make routing easier to investigate. Operators can inspect which rule matched and why instead of inferring the decision from where a query happened to run.

Fleet Commander does not eliminate failures or guarantee faster SQL. It gives operators a clearer way to control placement and understand the decisions being made.

The Handoff Between Routing and Lifecycle Management

Having available clusters doesn't guarantee that a query will reach the right one. The decision depends on the workload's policy, the cluster's eligibility and a reliable view of current load.

Fleet Commander brings these factors into the routing process instead of relying on fixed destinations. But a cluster's state can change after a query has been assigned. It may need to scale down or be removed while queries are still running. Routing determines where new work goes. Managing that transition without disrupting in-progress work is a different engineering problem.

Read Part 2: Managing Trino Cluster Lifecycles Safely.

Operating Snapshot

The recorded sample covers 951,982 query records. Its engine-recorded latency and queue percentiles describe the workload handled by the platform, not complete dashboard refresh times. Timing fields have different coverage across recorded states, so this is an operating snapshot rather than a before-and-after comparison.

AreaMeasurement
Overall query latencyp50: 794 ms; p95: 84.6 s
Overall queue timep50: 4.06 s; p95: 163.2 s
BI workload55,477 queries
BI query latencyp50: 2.94 s; p95: 57.8 s
BI queue timep50: 1.77 s; p95: 79.2 s

Interpreting BI Latency

Our historical BI p95 baseline was approximately 10 seconds; the recorded sample has a BI elapsed-time p95 of 57.8 seconds. The populations and measurement definitions have not been reconciled, so these figures cannot support a runtime-reduction claim. BI already had dedicated capacity in the old setup; expensive BI queries could still delay other BI work.

Queueing showed a particularly long tail across some workloads. At p95, queue time reached 245.4 seconds for scheduled queries, 264.6 seconds for slow BI queries and 1,508.9 seconds for ETL queries.

The recorded workload distribution was 72.91% scheduled queries, 10.11% cube, 5.98% Sugarfit, 5.83% BI, 4.64% slow BI, and 0.53% ETL. This mix shows the range of workloads the platform handles, rather than proving an improvement over the old topology.

Posted
Nov 24, 2026
 in 
Engineering
 category

More from 

Engineering

 category

View All
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.