Skip to content

Gateway-Level Query Queue for Trino Gateway #801

@jalpan-randeri

Description

@jalpan-randeri

Summary

Add support for a gateway-level query queue in Trino Gateway to manage and control the flow of incoming queries before routing them to backend clusters.

Motivation

Currently, Trino Gateway routes queries directly to clusters based on routing logic and resource groups. In high-traffic scenarios, this can lead to backend overload, uneven resource utilization, or dropped queries. A gateway-level queue would allow for better traffic management, prioritization, and smoother handling of bursts.

Proposed Solution

Implement a configurable queue at the gateway level to hold incoming queries.

  • Support queue policies (FIFO, priority, max queue size, etc.).
  • Integrate with existing routing and resource group logic.
  • Provide metrics and monitoring for queue status.
  • Expose queue configuration and status via API and/or UI.

Benefits

  • Prevent backend overload by controlling query admission rate.
  • Enable prioritization and fairness across users or workloads.
  • Improve reliability and user experience during peak loads.
  • Ability to move idempotent queries across clusters
  • Automated query retries across clusters
  • Safe rollout out new version/ shadow testing

While we relying solely on backend cluster-level queuing (less visibility/control at gateway). We are running into very brittle
Implementing custom throttling logic outside the gateway.

I am willing to create detailed specifications and participate in design reviews to help move this feature forward. Please let me know how best to proceed with further review and collaboration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions