The sandbox instance warm pool automatically maintains a group of pre-started sandbox instances for sandbox applications. This ensures that instances can be allocated within tens of milliseconds after requests to create sandbox instances are initiated. This eliminates cold start.
warning
- Instances in the warm pool are pre-started on the user side, which consumes resources and incurs corresponding fees. For specific billing details, see Pay-as-you-go - Cloud Sandbox.
- After you enable the warm pool, some parameters cannot be modified during sandbox instance creation. Otherwise, the warm pool cannot be matched. For detailed parameter description, see Step 2Step 2Step 2 in this document.
In the default process, each time you create a sandbox instance, it must go through image pulling, instance start, runtime initialization, and other steps, resulting in cold start delays of several seconds or longer. The sandbox instance warm pool pre-starts and maintains a batch of idle instances in a ready state, moving this time-consuming process ahead of the request arrival, so allocation can be nearly instantaneous.
Allocation and replenishment process
Through the warm pool, the system maintains a set of sandbox instances in a ready state in the background. When you call the CreateSandbox API or create a sandbox instance in the console, the system preferentially allocates instances from the resource pool. This significantly reduces latencies.
Resource pool replenishment
To keep the warm pool size at the expected level, the system automatically replenishes resources based on instance consumption. The resource pool replenishment logic of the platform is calculated by using the following formula: QPS = Resource pool size/Sandbox instance creation time (s).
- Resource pool size: The number of warm pools set by the user in Resource quotas.
- Sandbox instance creation time: The average instance creation time obtained through real-time system monitoring.
The system dynamically adjusts the replenishment speed based on the calculated QPS rate to ensure the resource pool size remains stable.
tip
The TOS dynamic mount capability is currently in the beta phase. To activate this feature, please submit a ticket. When creating a sandbox instance, you can dynamically map the specified TOS bucket (and subdirectories) as a local directory within the instance based on the parameters passed in the current request. The instance can access TOS data as if it were reading and writing local files. The mounted bucket, path, and authentication information are passed with each CreateSandbox request. Different requests can mount different data, enabling data isolation and reuse between instances, without the need to modify the image or code. When the number of TOS mount points matches the number of pre-warmed instances, the following information does not affect whether a pre-warmed instance is matched.
- Authentication information: AccessKeyId, SecretAccessKey
- Mounted bucket: BucketName
Sandbox instance pre-warming is suitable for the following usage scenarios.
Step 1: Configure the pre-warmed pool size
- In the top navigation bar, select the target region.
- In the left navigation pane, click Cloud sandbox > Sandbox app. Find the target sandbox application and click its name.
- On the sandbox application details page, click the Sandbox instance tab.
- In the Resource quotas section of the Sandbox instance tab, click Settings to specify the Warm pool size parameter.
- Click Confirm to complete the configuration.
- After the configuration is complete, the system will start as many sandbox instances as specified, with their initial Start type set to Pre-warmed-Idle.
Step 2: Use the sandbox instance pre-warmed pool
On the Sandbox instance tab, click Create sandbox instance. For details, see Creating sandbox instances. At this point, veFaaS will preferentially allocate a Warmed - Idle instance from the warm pool, and its status will change to Warmed - allocated. In addition, the system will immediately start a new sandbox instance to replenish the warm pool to maintain the preset warm pool size. warning
Take note of the following items when you create a sandbox instance:
- If you change the instance lifecycle duration, instance metadata, or TOS bucket, idle instances can still be allocated from the pre-warmed pool.
- If you modify parameters such as Instance specification and Execution timeout, idle instances cannot be allocated from the warm pool, and new instances will be created by default.
Step 3: Resource monitoring
On the Sandbox app details page, click the Monitoring tab. Then, click Cloud Sandbox Reserved Instance Pool Monitoring to view the running status and instance allocation status of the warm pool. You can also perform the following operations:
- Click Create alert strategy to go to the Cloud Monitor console and configure an alert policy for the current sandbox application. When a metric meets the trigger condition for an alert, the system will send an alert notification through your specified method. This helps you promptly identify service exceptions. For specific operations, see Creating alert policies.
Step 4: (Optional) Turn on and use TOS dynamic mount
Call CreateSandbox to create an instance. Specify the TOS bucket to mount this time through InstanceTosMountConfig, and the system will dynamically complete the mount when creating the instance. The configuration example is as follows.