Run Spark jobs at approximately 30% lower cost by enabling spot instances for your job resource groups. Spot instances use idle Spark executor resources at a discounted rate — with a trade-off: they can be preempted when on-demand rises.
Prerequisites
Before you begin, ensure that you have:
An AnalyticDB for MySQL cluster (Enterprise Edition, Basic Edition, or Data Lakehouse Edition)
A job resource group, or plan to create one
How it works
When you submit a Spark job in a job resource group with spot instances enabled, AnalyticDB for MySQL attempts to acquire idle spot instance resources first.
If preemption succeeds — the job runs on spot instance resources and is billed at the spot rate (approximately 30% less than ACU elastic resources).
If preemption fails — the job falls back to ACU (AnalyticDB Compute Unit) elastic resources and is billed at the standard rate.
After spot instance resources are acquired, a 1-hour protection period begins. Resources are not preempted during this window. After the protection period ends, resources may be reclaimed — the probability increases with usage duration. The overall job failure rate due to spot preemption is 1% to 5%.
Onlylargeand2xlargeSpark executor specifications support spot instances. See Spark application configuration parameters for details.
Choose a spot instance strategy
Use the following table to match your workload to the right strategy.
| Workload | Recommended strategy | Reason |
|---|---|---|
| Development and testing | Spot instances for all jobs | Low cost; occasional failures are acceptable |
| Cost-sensitive batch jobs | Spot instances for all jobs | Jobs can tolerate retries; most complete within 1 hour |
| Mixed workloads | Spot for short jobs; on-demand for long jobs | Separate resource groups by expected job duration |
| Mission-critical production | On-demand only | Failures directly impact business operations |
| Long-running jobs (>1 hour) | On-demand only | High preemption probability after the 1-hour protection period |
Mixed workload strategies
Option 1 — Separate resource groups
Create two job resource groups: enable spot instances for the group running short jobs, and leave it disabled for the group running long or critical jobs.
Option 2 — Per-job override
Enable spot instances at the resource group level, then set spark.adb.spotInstance.disabled=true on individual jobs that must not use spot instance resources.
Limitations
Spot instances are available in the following regions: China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hangzhou), China (Shanghai), China (Shenzhen), China (Guangzhou), China (Hong Kong), Japan (Tokyo), Singapore, US (Silicon Valley), US (Virginia), Germany (Frankfurt), and UK (London).
Spot instances are supported only for job resource groups.
Only Spark jobs can use spot instance resources.
Only
largeand2xlargeSpark executor specifications support spot instances.
Billing
Spot instance resources cost approximately 30% less than ACU elastic resources. For pricing details, see Pricing for Enterprise Edition and Basic Edition. For Data Lakehouse Edition pricing, see Pricing for Data Lakehouse Edition.
Enable spot instances
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster and click the cluster ID.
In the left-side navigation pane, choose Cluster Management > Resource Management. Click the Resource Groups tab.
For an existing job resource group
Find the job resource group and click Modify in the Actions column.
In the Modify Resource Group panel, turn on Spot Instance.
Click OK.
Verify that the Spot Instance column for the resource group shows the feature as enabled.
After enabling spot instances, Spark jobs in this resource group attempt to use spot instance resources.
Create a new job resource group with spot instances
Click Create Resource Group in the upper-right corner.
Configure the resource group with the following parameters:
Parameter Description Resource group name 2–30 characters. Can contain letters, digits, and underscores ( _). Must start with a letter.Job type Select Job. Job resource groups scale compute on demand for high-throughput batch processing. Minimum computing resources Set to 0ACUs.Maximum computing resources Set a value between 8 ACUs and 1,024 ACUs in increments of 8 ACUs. To increase the upper limit, submit a ticket. Spot Instance Turn on Spot Instance. Click OK.
Verify that the Spot Instance column for the new resource group shows the feature as enabled.
Disable spot instances for a specific Spark job
To prevent a single Spark job from using spot instance resources without changing the resource group configuration, set the following parameter in the CONF section of the job:
| Parameter | Required | Description |
|---|---|---|
spark.adb.spotInstance.disabled | No | Set to true to disable spot instance usage for this job. Default: false (spot instances enabled). |
After the job completes, check the Spot Instance Resource Usage value on the job details page. A value of 0 confirms that the job did not use spot instance resources.
Monitor spot instance usage
After a Spark job completes, go to the Monitoring page of the job resource group to view spot instance resource usage.
Disable spot instances
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster and click the cluster ID.
In the left-side navigation pane, choose Cluster Management > Resource Management. Click the Resource Groups tab.
Find the job resource group and click Modify in the Actions column.
In the Modify Resource Group panel, turn off Spot Instance.
Click OK.
Verify that the Spot Instance column shows the feature as disabled.
API reference
| API | Description |
|---|---|
| CreateDBResourceGroup | Creates a resource group for AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition clusters. |
| ModifyDBResourceGroup | Modifies a resource group for AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition clusters. |
| DescribeDBResourceGroup | Queries resource group information for AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition clusters. |
| DescribeClusterResourceDetail | Queries resource usage information for AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition clusters. |