Spark Agents
When migrating Apache Spark and Hadoop workloads from on-premises environments to Amazon EMR, one of the most common and time-consuming steps is upgrading from the on-premises Spark version to the version supported on the target EMR release. Traditional Spark version upgrades require months of engineering effort to analyze API changes, resolve dependency conflicts, and validate functional correctness. AWS provides two AI-powered agents that address these challenges. The Spark Upgrade Agent automates code transformation, dependency updates, and data quality validation to compress upgrades from months to weeks. The Spark Troubleshooting Agent analyzes Spark event logs, error messages, and resource usage to pinpoint root causes, reducing troubleshooting from hours to minutes.
Overview of Apache Spark agents for EMR
AWS offers two primary Spark agents designed specifically for migration scenarios.
Apache Spark Upgrade Agent
The Apache Spark Upgrade Agent is a conversational AI capability that accelerates Apache Spark version upgrades for EMR applications. Traditional upgrades require months of engineering effort to analyze API changes, resolve dependency conflicts, and validate functional correctness. This agent transforms upgrades from high-risk, resource-intensive projects into manageable workflows that fit within normal development cycles.
The agent provides the following key capabilities:
-
Converts complex upgrade processes that typically take months into weeks through automated code analysis and transformation.
-
Supports upgrades from Spark 2.4 to 4.x across PySpark and Scala applications.
-
Works with Amazon EMR on EC2 and EMR Serverless.
-
Compresses upgrade timelines from months to weeks through automated code analysis, dependency resolution, and validation. For more information, see What is Apache Spark Upgrade Agent for Amazon EMR.
-
Maintains 100% semantic equivalence and data processing accuracy throughout the upgrade process.
Apache Spark Troubleshooting Agent
The Apache Spark Troubleshooting Agent streamlines diagnosing Spark failures, saving data engineers and scientists significant time by analyzing workloads and providing actionable recommendations through natural language prompts.
The agent provides the following key capabilities:
-
Reduces troubleshooting time from hours to minutes.
-
Analyzes logs, metrics, and configurations across Amazon EMR on Amazon EC2 and EMR Serverless.
-
Provides specific code recommendations for PySpark applications.
-
Identifies root causes automatically without manual investigation.
Architecture and deployment
Both agents are built on a modern, cloud-native architecture using the Model Context Protocol (MCP).
Core components
-
MCP Client Layer — user interaction through Kiro CLI or Kiro IDE (AWS AI-powered development environment, customer's local environment), SageMaker Unified Studio JupyterLab Spaces (AWS managed compute), or any MCP-compatible AI assistant in your local development environment.
-
MCP Proxy for AWS (customer's local environment) — handles secure communication between your client and the MCP server with IAM role-based authentication.
-
IAM Role and S3 Staging Bucket (customer's AWS account) — CloudFormation-provisioned IAM role with permissions to call the MCP server and access EMR resources, plus an S3 bucket for staging upgrade artifacts.
-
Amazon SageMaker Unified Studio Managed MCP Server (preview) (AWS managed) — provides specialized Spark upgrade and troubleshooting tools for EMR.
-
Target Infrastructure (customer's AWS account) — EMR on EC2 or EMR Serverless clusters where validation jobs execute.
All actions are recorded in AWS CloudTrail for full auditability.
Spark Upgrade Agent: how it fits in your migration
When migrating from on-premises Spark (for example CDH or HDP running Spark 2.4) to EMR 7.x running Spark 3.5/4.x, the upgrade agent handles the end-to-end application upgrade in five stages. It analyzes your codebase and generates an upgrade plan, updates build configurations and dependencies, applies targeted code edits to resolve API incompatibilities, submits validation jobs to your target EMR cluster, and tracks progress throughout. The agent uses an error-driven approach, fixing one issue at a time based on actual compilation or runtime errors rather than applying bulk changes.
The following list describes what this means for your migration:
-
You provide — your application code (cloned locally with Git), and a target EMR cluster or EMR Serverless application running the desired Spark version.
-
The agent handles — dependency updates, deprecated API replacements, build fixes, remote validation, and data quality comparison between source and target outputs.
-
You retain control — all code changes are explained and shown before being applied, and you approve each modification.
For the complete stage-by-stage workflow, see Spark Upgrade Agent Workflow In Details.
Spark Troubleshooting Agent: how it fits in your migration
During migration, Spark applications that ran successfully on-premises often fail on EMR due to differences in Spark versions, cluster configurations, resource allocation, or S3 access patterns versus HDFS. Traditional troubleshooting requires manually sifting through driver and executor logs, YARN container logs, and CloudWatch metrics across a distributed system, a process that can take hours or days. The Troubleshooting Agent automates this by analyzing your failed Spark application's event logs, error messages, and resource usage to pinpoint the exact issue (an executor running out of memory, a configuration error, or a code bug), then provides a clear root cause explanation and specific code recommendations to fix it.
The following list describes common migration-specific scenarios:
-
OOM failures after migration — your application fit in memory on-premises but fails on EMR due to different executor memory defaults or data distribution changes when reading from S3 instead of HDFS.
-
Performance degradation — jobs run slower on EMR than on-premises due to S3 access patterns, shuffle configuration differences, or suboptimal cluster sizing.
-
API behavior changes — upgraded Spark version changes query plan behavior, causing jobs to fail or produce unexpected results.
What you need: access to your failed Spark application identifiers on a supported platform (Amazon EMR on Amazon EC2, EMR Serverless, or AWS Glue) with accessible logs and Spark History Server. The agent connects to EMR Persistent UI (for Amazon EMR on Amazon EC2) or Spark History Server (for EMR Serverless) to retrieve Spark event information.
For the complete workflow and supported platforms, see Apache Spark Troubleshooting Agent Features and Capabilities.
Data quality validation
The upgrade agent can validate that your application produces equivalent results after upgrading Spark versions. You provide both a source and target EMR cluster ID, and the agent runs your application on both and compares outputs for schema differences, statistical drifts, and row-count mismatches. Both clusters must be EMR clusters; the agent cannot connect to on-premises Spark environments. To validate during migration, first migrate your data to S3, then provision a source EMR cluster matching your current on-premises Spark version alongside your target EMR cluster. Data quality validation requires Spark 3.0+ on the source cluster and only tracks Spark write operations. For more information, see Enable Data Quality Validation.
Migration best practices
-
Pre-migration assessment — deploy the assessment dashboard to understand your EMR footprint, identify all Spark applications, document dependencies and custom UDFs, and review data sources.
-
Version support — Amazon EMR on Amazon EC2 supports upgrades from EMR 5.20.0+ to EMR 7.12.0; EMR Serverless supports 6.6.0+ to 7.12.0.
-
Upgrade coverage — build configuration, source code API compatibility, test code, dependencies, validation, and data quality checks.
Cost and benefits
The Spark agents are available at no additional cost with Amazon EMR. You only pay for underlying resources during validation.
The agents provide the following benefits:
-
Time savings — months to weeks; typical applications 8 hours to 30 minutes.
-
Risk reduction — automated validation, data quality checks, iterative error correction up to 3 retries.
-
Operational efficiency — natural language interface, full approval control, CloudTrail audit trail.
IDC research reports the following outcomes for customers who migrated to Amazon EMR:
-
56% year-one cost savings versus on-premises Hadoop.
-
3.5 times faster Spark workload performance.
-
626% five-year return on investment.
-
99% reduction in unplanned downtime.
Integration with EMR migration strategy
The agents complement the AWS EMR Migration Acceleration Program, enabling compute and storage separation (S3 and EMR), increased agility, managed services, cost optimization (Spot instances), and performance improvements (EMR runtime 4.5 times faster than Apache Spark 3.5). Complementary tools include AWS DMS, Amazon MSK, Step Functions, and MWAA.
Real-world migration patterns
-
Lift-and-shift with modernization — assess, migrate, upgrade, and optimize with EMR features.
-
Gradual migration — pilot non-critical workloads, validate, expand incrementally, and decommission on-premises.
-
Hybrid approach — use EMR on AWS Outposts for on-premises presence, maintain consistent tooling, and gradually shift to cloud.
Common migration issues
The Troubleshooting Agent addresses the following common migration issues:
-
Job failures — analyzes logs and configurations, and provides root cause analysis and code recommendations.
-
Performance degradation — identifies configuration issues, and recommends EMR optimizations.
-
Data inconsistencies — validates schema compatibility, and checks API behavior changes.
Documentation and next steps
The following resources provide more information about the Spark agents:
-
MCP Proxy for AWS
To get started, follow these next steps:
-
Deploy the assessment dashboard.
-
Install Kiro powers in your IDE.
-
Start with a pilot application.
-
Validate thoroughly using data quality checks.
-
Scale gradually to additional applications.