# How Zomato Scaled Data Analytics with Trino
*How Zomato scaled Trino for growing analytics workloads using workload tuning, monitoring, custom autoscaling, and a multi-cluster gateway.*
By [Rohit Lakhotia](https://scaleengineer.com/authors/rohit-lakhotia)
Published: 2026-10-19
Canonical: https://scaleengineer.com/blog/how-zomato-scaled-data-analytics-with-trino
---
At Zomato, different teams constantly ask different questions from their data\.

A City Lead might want to know how many orders were placed in NCR last week\. Customer Support might want to track how many queries were resolved within a minute\. The Product team might analyze participation in the Zomato Premier League, while the Social Media team might look at the most\-searched dishes on New Year's Eve\.

The questions are different, but they all have something in common: **Someone needs to query a lot of data and get the results quickly\.**

Zomato uses **Trino** as its query engine to power analytical systems, experiments, and ML models over its data lake\. Trino also allows Zomato to query and join data across different sources such as **Apache Hive, MySQL, Apache Druid, Apache Pinot, and MongoDB**\.

But as the number and variety of queries grew, simply running a query engine wasn't enough\. Zomato had to figure out how to **handle different workloads, monitor queries, scale the clusters, and eventually manage multiple Trino clusters\. **Let’s discover today in this blog on how they approached it\.

## Different Queries Need Different Treatment

Zomato found that its query workloads could broadly be divided into three categories\.

### 1\. Scheduled ETLs and Reports

These are long\-running queries that can take **up to 3 hours**\. They are typically used for materialised views that help speed up dashboard queries\. Zomato runs these through an internal platform built on Apache Airflow, which also has a full query retry mechanism\.

### 2\. Dashboard Queries

These are much shorter, with runtimes of **up to 3 minutes**\. They are primarily used for dashboards that monitor different business processes\.

### 3\. Ad\-hoc Analysis

These queries can run for **up to 20 minutes** and are used for things like debugging and other ad\-hoc analysis\. This classification gave Zomato an important insight:

**Not every query should be treated the same way\. **Based on these usage patterns, they could tune clusters individually for better performance and robustness\.

## Running Trino at Zomato

Zomato runs Trino on **Amazon ECS** using a custom Trino image\. They added several components around Trino to make it work better for their environment\.

### Query Logging

Zomato built a custom **Trino query\-log plugin** using Trino's Event Listener framework\. The plugin logs completed queries and uses that information to build metrics for their Trino monitoring dashboard\.

The team also analyzes query patterns to tune their Hive table layouts, including data\-file sizes and column\-level indexing using **Bloom filters**\. They also calculate column\-level statistics to help Trino's **Cost\-Based Optimizer** make better decisions\.

### Custom Functions

Zomato also created custom **Trino User Defined Functions \(UDFs\)** based on its requirements, including custom geographical functions\.

### Testing New Trino Versions

Before rolling out a new Trino version, Zomato benchmarks the new version to measure query performance\.

They also use **Trino Verifier** to compare the results produced by two different clusters\. This helped them identify backward\-incompatible changes before deploying a new version\. For example, they used this approach to identify a backward\-incompatible timestamp change in **Trino version 341**\.

## Watching the Clusters in Real Time

Trino distributes queries across multiple workers\. That makes monitoring and debugging more complicated because a problem can involve different parts of the cluster\. Zomato uses **Trino JMX and Docker container metrics** to create real\-time monitoring dashboards\.

Some of the alerts they set up include:

- P95 query execution and queued time
- Number of active workers
- Query failure rates
- Number of queued and running queries

They also analyze query logs to identify **queries that are consuming too many resources** and regularly look at metrics such as bytes scanned, total stages, and total runtime to fine\-tune their cluster configuration\.

## The Scaling Problem

As Zomato's data\-driven analysis grew, its Trino workload grew too\. And with more workload came higher infrastructure costs\. The team initially realized that **time\-based autoscaling wasn't enough**\.

They needed to:

1. Scale the cluster according to actual traffic\.
2. Gracefully shut down unnecessary nodes during off\-peak periods\.

The challenge was that Trino couldn't simply be scaled like a typical service using CPU or memory metrics\. So Zomato experimented with different scaling conditions\. Eventually, they settled on a metric based on the ratio between **running queries and active workers**\.

The cluster would scale up when:

**running queries / active workers > threshold**

and scale down when the ratio dropped below the threshold\.

Zomato calculated this threshold using factors such as the **maximum number of nodes, maximum concurrent queries, and maximum query memory per node**\.

The result was a more workload\-aware autoscaling approach\. According to Zomato, this custom autoscaler reduced the Trino cluster cost by **30–40%**, while achieving **zero downtime during downscaling**\.

## One Cluster Wasn't Enough

Even with the custom autoscaler, Zomato continued to experience cluster slowdowns as its scale increased\. The team concluded that **a single Trino cluster would not be enough to scale indefinitely**\.

So they moved toward a **multi\-cluster architecture**\. To manage multiple Trino clusters, Zomato adopted **Presto Gateway**, an open\-source load balancer, proxy, and gateway for Presto/Trino clusters originally developed by Lyft\.

The gateway sits between Zomato's visualization tools and SDKs and the underlying Trino clusters\. This meant those tools didn't have to be tightly coupled to a particular Trino cluster or version\.

Zomato also added functionality around the gateway, including:

- Converting `X-Presto` headers to `X-Trino` headers for backward compatibility
- Overall Presto cluster health visibility
- Query cost and estimation\-based routing

## The Bigger Picture

Trino became an important part of Zomato's data platform, supporting use cases including **analytics, reporting, data quality, and lineage tracking**\.

But the interesting part of this story isn't just **“Zomato uses Trino\.” **It's how the surrounding infrastructure evolved as the workload grew: **Different workloads → workload\-specific tuning → monitoring → custom autoscaling → multiple clusters → gateway\-based routing**

The main challenge wasn't simply making queries work\. It was making the entire analytics platform **reliable, observable, and efficient as the number of queries increased\.**

## Key Takeaways

- **Different workloads need different treatment\.** Zomato separated scheduled ETLs, dashboard queries, and ad\-hoc analysis so clusters could be tuned according to their workload\.
- **Query\-level observability matters\.** Zomato used query logs and metrics such as execution time, queued time, failures, bytes scanned, and runtime to monitor and tune Trino\.
- **Autoscaling needs to understand the workload\.** Instead of relying only on CPU or memory, Zomato scaled using the ratio of running queries to active workers\.
- **Scaling isn't always about adding more capacity to one cluster\.** As workloads increased, Zomato moved toward a multi\-cluster setup and introduced Presto Gateway to manage traffic across clusters\.
- **The custom autoscaler reduced cluster costs by 30–40%**, while Zomato reported zero downtime during downscaling\.

Official blog from Zomato: **[Powering Zomato’s data analytics using Trino](https://www.zomato.com/blog/powering-data-analytics-with-trino/)**

By now, you must have had a clear idea of,** How Zomato Scaled Data Analytics with Trino? **In a nutshell, Zomato uses Trino to query data across multiple sources and support analytics, experiments, and ML workloads\. As query volume grew, Zomato introduced workload\-specific tuning, monitoring, custom autoscaling, and eventually a multi\-cluster setup using Presto Gateway\.

**Congratulations\! You've just advanced another step in your tech journey\. Keep progressing\!**
