PAI-EAS Spot is a cost-effective solution for deploying online inference services using spot instances. It is ideal for cost-sensitive applications that can tolerate occasional response delays. This topic provides best practices for using PAI-EAS Spot to help you reduce costs while maintaining service stability.
Scenarios
Non-critical workloads: Applications where occasional service interruptions have minimal impact.
Fault-tolerant processing: Applications that can handle brief service unavailability through retry mechanisms or other fault-tolerance strategies.
High cost-optimization needs: Projects or businesses aiming to lower operational costs using flexible and inexpensive compute resources.
Spot service configuration method
Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Elastic Algorithm Service (EAS).
Click Deploy Service In the Inference Service section, click Custom Deployment in the Custom Model Deployment section.
In the resource deployment section, set Resource Type to Public Resources. Choose a resource specification (L or H series instances are recommended), enable Spot mode, and enter your bid price. You can click the historical price curve to view market prices for the past 48 hours as a bidding reference.
In the Deployment Resources section, add multiple resource specifications. For each, toggle the Spot switch and set a bid price. Set Spot Instance Retention Duration to No Guaranteed Protection Period.
ImportantYour bid price is not the same as your actual payment price—the market price determines what you pay. Your bid reflects the maximum price you are willing to pay. As long as the market price stays below your bid, your instance remains active. During this time, you pay the current market price, not your bid.
We strongly recommend setting your bid to 20% of the list price. For example, the pay-as-you-go list price for an 8-core, single-GPU L20 instance is CNY 14.4 /hour. Current Spot prices never exceed 20% of the list price—CNY 2.88 /hour in this case. This strategy ensures stable access to resources at a significant discount. For more information, see Spot instance selection.
Configure regular (on-demand) instances alongside Spot instances to avoid deployment failures if Spot capacity is unavailable.
After successful deployment, you can review price fluctuations for the past 48 hours on the EAS service details page to better understand cost changes. In the Service Instances section, view the status of your Spot instances. Click an instance to open the right-side panel, which displays a line chart titled Instance Specification Price (CNY/hour). The blue solid line shows the original list price, and the purple dashed line shows the Spot market price in the zone.
Spot instance reclaim and fault tolerance
EAS platform reclaim mechanism
When a Spot instance is about to be reclaimed, EAS typically receives a warning notification approximately 5 minutes in advance. Upon receiving this notice, the instance begins a graceful shutdown to smoothly drain traffic and prevent request failures. Simultaneously, EAS automatically launches a new instance, attempting deployment in the order specified in your resource configuration. This process minimizes disruption and ensures smooth business continuity.
Configure pay-as-you-go regular instances to prevent total service outage if all Spot instances are reclaimed. This ensures service continuity and stability.
Switching back to Spot instances after reclaim
If your service switches to regular instances after a Spot reclaim and you want to switch back to Spot instances once inventory becomes available, use the Instance Recreation feature.
The Instance Recreation feature releases the current instance and creates a new one with identical settings:
In the Service Instances section, click the dropdown menu in the Actions column for your target instance and select Instance Recreation.
User configuration recommendations
When a Spot instance is about to be reclaimed, EAS automatically starts a new instance and initiates a graceful shutdown. To improve service stability, reliability, and startup speed, follow these configuration recommendations.
Configure multiple instance types
To ensure service stability and reliability, use a diversified instance strategy by selecting multiple resource specifications. Crucially, include at least one regular (non-Spot) instance type as a fallback option. EAS will attempt to deploy instances in the order you specify, maximizing the chance of successful startup and continuous operation. For more information about multi-specification instance selection, see Multi-specification instance selection.
In the Deployment Resources section, add up to 10 resource specifications. Set a Bid Price (CNY/hour) for each Spot instance. For Spot Instance Retention Duration, choose either No Guaranteed Protection Period or Guarantee 1 Hour of Usage.
Enable local directory memory cache
To speed up model file loading when a new instance starts after a Spot reclaim, configure local directory memory caching. This uses idle node memory to cache model files from the local directory. New instances can then load models directly from memory instead of reading from the mounted centralized data storage, reducing initialization time and minimizing service downtime during scaling.
Enable memory cache acceleration during EAS service creation to improve scaling efficiency. For more information, see Model cache acceleration.
In the Service Features section, turn on Memory Cache Acceleration. After enabling it, click Modify Configuration to adjust cache parameters.
The performance improvement from enabling memory cache acceleration (cachefs) is shown in the table below. Using Stable Diffusion model switching as an example, compared to loading models directly from an OSS-mounted directory, enabling cachefs allows new instances to read models from the memory of other running instances (remote cachefs hit), significantly reducing model loading time.
Model | Model size | Model loading time (s) | |
OSS mount | cachefs remote hit | ||
anything-v4.5.safetensors | 7.2G | 89.88 | 15.18 |
Anything-v5.0-PRT-RE.safetensors | 2.0G | 16.73 | 5.46 |
cetusMix_Coda2.safetensors | 3.6G | 24.76 | 7.13 |
chilloutmix_NiPrunedFp32Fix.safetensors | 4.0G | 48.79 | 8.47 |
CounterfeitV30_v30.safetensors | 4.0G | 64.99 | 7.94 |
deliberate_v2.safetensors | 2.0G | 16.33 | 5.55 |
DreamShaper_6_NoVae.safetensors | 5.6G | 71.78 | 10.17 |
pastelmix-fp32.ckpt | 4.0G | 43.88 | 9.23 |
revAnimated_v122.safetensors | 4.0G | 69.38 | 3.20 |
Use Enterprise Edition ACR
To speed up image pulling when new instances start after a Spot reclaim, use Enterprise Edition ACR with image acceleration enabled. Deploy EAS services using accelerated images by appending _accelerated to the standard image URL. When deploying, select the VPC network associated with your Enterprise Edition ACR instance.
Use Enterprise Edition ACR with a Standard Edition instance type. Enable image acceleration when creating your image repository to improve scaling efficiency. For more information, see Image acceleration.
In the image acceleration options, select Full Mode.
Combine with elastic scaling
When your workload has significant peaks and troughs, enable horizontal auto-scaling. Use a combination of dedicated resource groups for baseline capacity + Spot resources for elasticity + regular resources as fallback to ensure smooth scaling and optimal cost efficiency. Follow this configuration strategy:
Purchase a set of EAS subscription or pay-as-you-go dedicated resource groups to guarantee minimum service capacity. In the console, configure GPU, CPU, and memory requirements in your dedicated resource group to ensure services can start reliably.
Enable the EAS Elastic Resource Pool and configure multiple resource specifications. Prioritize Spot resources in your sorting order, with regular resources as the last fallback. This ensures that during traffic peaks, scaling first uses available Spot capacity and falls back to regular resources only when Spot inventory is insufficient—balancing cost savings and reliability.
Configure three resource types in the elastic resource pool: ecs.gn8v-8x.48xlarge (Spot enabled, bid CNY 33 /hour) and ecs.gn8is-8x.32xlarge (Spot enabled, bid CNY 25 /hour) as Spot resources, and ml.gu7i.c8m30.1-gu30 (Spot disabled) as the fallback. Set Spot Instance Retention Duration to Guarantee 1 Hour of Usage.
After deploying your service, enable horizontal auto-scaling on the service details page based on business metrics. Scale automatically using metrics such as QPS, CPU utilization, GPU utilization, or queue length, or define custom metrics.
In the Auto Scaling Settings dialog box, set the Minimum Instances and Maximum Instances (for example, 2 and 10). Select a scaling metric and set a threshold (for example, set GPU Utilization Threshold to 60%), then click Enable.
You can also enable scheduled scaling to align with predictable traffic patterns over time.
In the Scheduled Auto Scaling Settings dialog box, click Add to create a scheduled task. Configure the Task Name, Target Instance Count, and Scheduling Cycle (choose from Weekly, Daily, or cron expression). Select the execution time, and the system will auto-generate the corresponding cron expression (for example,
0 0 9 * * *runs daily at 9 AM). Click OK when done.
When creating instances, EAS prioritizes dedicated resource group capacity first, then cycles through available resources in the elastic resource pool in your specified order.
For example, if your dedicated resource group is fully used and additional instances are needed from the public resource pool, the system first checks how many ecs.gn8v-8x.48xlarge instances can be created. If insufficient, it checks ecs.gn8is-8x.32xlarge. If both are unavailable, it uses ml.gu7i.c8m30.1-gu30 for the remaining instances.
For example, to scale out 8 instances beyond your dedicated resource group, you might end up with 2 instances in the dedicated group, 3 on ecs.gn8v-8x.48xlarge, 2 on ecs.gn8is-8x.32xlarge, and 3 on ml.gu7i.c8m30.1-gu30.
For detailed instructions on EAS elastic configuration, see the following documents: