0:0034:49

Beyond Manual Tuning: How RL Agents Learned to Optimize Apache Spark

Hina Gandhi 34:49 2026

Spark's 200-partition default fails small jobs and skewed ones alike

Split a 1,000-row job into Spark's default 200 shuffle partitions and it drowns in empty tasks; give a skewed monthly job the same setting and it hits stragglers and memory pressure. Data teams answer with endless rounds of tweak and rerun. Cisco software engineering technical leader Hina Gandhi shows a Q-learning agent that picks configurations before a job starts, but can learned tuning beat Spark's own runtime fixes, or does it need them?

See the agent's design, the benchmark numbers and a multi-agent blueprint for self-tuning Spark

Watch on YouTube

In short

Hina Gandhi, Software Engineering Technical Leader at Cisco, shows how a Q-learning agent wrapped around the Spark driver learns to choose configurations such as shuffle partitions before a job runs. She argues that pairing this pre-execution intelligence with Spark's Adaptive Query Execution beats either approach alone, reporting 46% and 68.6% gains in her experiments, and proposes a multi-agent design with a deterministic coordinator for memory, compute and caching.

“So the exact same configuration leads to completely opposite problems depending on the workload.”
“If you have only RL, you are smart upfront, but blind during execution. If you only have AQE, you react well, but start from, you know, suboptimal decisions.”

What you will learn

  • Explain why a static Spark default such as 200 shuffle partitions over-parallelizes small jobs and overloads large skewed ones.
  • Design a non-intrusive Q-learning wrapper that samples a dataset, buckets size, cardinality and skew, and picks configurations before execution.
  • Tune exploration with an epsilon that decays over time but never drops to zero, so the agent keeps adapting to changing code and data.
  • Combine pre-execution RL decisions with Spark's Adaptive Query Execution to capture complementary performance gains.
  • Structure multi-parameter optimization as specialist agents coordinated by a simple deterministic orchestrator rather than one monolithic AI.

Key takeaways from the speaker

  • How Q-learning agents learn from job execution feedback to build configuration policies
  • Why hybrid RL+AQE optimization outperforms either approach alone
  • Multi-agent architecture for scaling autonomous optimization across all Spark parameters
  • Practical deployment strategies for production environments

Details

Level
Intermediate
Format
Tech talk
Technical depth
Practitioner
For
Mid-career, Senior individual contributor
Length
34:49
Published
June 2026

Questions this talk answers

Why doesn't Adaptive Query Execution solve Spark tuning on its own?

AQE only kicks in after a job has started executing, so the cost of suboptimal initial decisions such as partitioning has already been incurred. It can correct course but cannot fully undo that inefficiency.

How does the RL agent understand a dataset without slowing the job down?

It samples a small set of rows (about 1,000 in her experiment, taking roughly 100 milliseconds) to estimate size, cardinality and skew, then groups these signals into buckets so similar workloads share learned configurations.

How much faster was the hybrid RL plus AQE approach?

As the speaker reported, on a 1,000-row low-skew dataset the hybrid ran in 0.142 seconds versus 0.263 seconds for AQE alone (46% faster), and on a 75,000-row skewed dataset in 0.143 seconds versus 0.457 seconds (a 68.6% improvement).

How do multiple learning agents avoid conflicting with each other?

Each agent (partition, memory, cache, core) learns independently in its own domain, and a lightweight coordinator that is not an AI applies their decisions in a fixed deterministic order, keeping the system predictable and debuggable.

How can a team start using this approach in production?

Start incrementally: instrument jobs to capture performance signals, add a lightweight Q-learning wrapper for pre-execution decisions, keep AQE enabled for runtime adaptation, and let the infrastructure learn from production traffic over time.

About this talk

Apache Spark's performance depends heavily on configuration parameters like shuffle partitions, memory allocation, and parallelism settings. Data engineering teams typically rely on static defaults (which rarely match workload reality) or time-consuming manual tuning that doesn't adapt as data patterns evolve. A configuration optimized for small daily reports fails catastrophically on massive end-of-month aggregations—yet tuning each workload variant manually is unsustainable as organizations process increasingly diverse datasets. This talk demonstrates how reinforcement learning transforms Spark configuration from a manual bottleneck into an autonomous, adaptive system. We built a Q-learning agent that observes dataset characteristics (size, cardinality, skew), experiments with different configurations, measures performance, and learns optimal settings for varying workload patterns—developing expertise comparable to experienced engineers but with perfect memory and systematic exploration. Through comparative experiments, we show that combining our RL agent with Spark's Adaptive Query Execution (AQE) delivers 46-68% performance improvements over AQE alone. The RL agent provides pre-execution intelligence by selecting optimal initial configurations, while AQE handles runtime adaptations—addressing complementary optimization opportunities. We then extend this to Multi-Agent Reinforcement Learning (MARL), where specialized agents independently optimize different domains: partitions, memory allocation, CPU cores, and caching strategies. Each agent becomes an expert in its area while collectively achieving comprehensive workload optimization, demonstrating a practical path toward intelligent, self-tuning big data infrastructure. Key Takeaways: 1.How Q-learning agents learn from job execution feedback to build configuration policies 2. Why hybrid RL+AQE optimization outperforms either approach alone 3. Multi-agent architecture for scaling autonomous optimization across all Spark parameters 4. Practical deployment strategies for production environments

Topics

Related talks

Browse the library

What Is NoSQL?

Heather Maga Business Owner / Software Developer, Copper Owl Development

In NoSQL, the database stops checking your data and the developer takes over

Beginner AI and data 2020