Function Compute provides instance-level events. You can use instance-level events to understand the lifecycle of a function instance, including the process of creating and destroying instances, and the points in time at which each step occurs. This topic describes the lifecycle of a function instance and the definition, change process, types, and query methods of instance-level events.
Lifecycle of a function instance
Instances of a function are dynamically created and destroyed based on the number of requests for the function. The lifecycle of each function instance includes the Creating, Running, and Destroying phases. The following figure shows the lifecycle of a function instance.

Creating
Function Compute creates function instances based on function configurations. The Creating phase includes code or layer loading (or image pulling), instance startup, and Initializer hook running. The following figure shows how Function Compute creates an instance.

- Elastic scaling: Function Compute creates instances if the existing function instances are fully loaded and unable to process new requests. In this case, a cold start occurs. For more information, see Best practice for reducing the cold start latency.
- Adjustment of provisioned configurations: Function Compute creates provisioned instances before requests are submitted if you specify a specific number of provisioned instances in the auto scaling rule of a function. Provisioned instances help prevent cold starts of instances. For information about the auto scaling feature, see Configure provisioned instances and auto scaling rules.
Running
Function Compute invokes the handler of your function to process requests. You can configure the instance concurrency of a function to modify the policy for processing requests. You can also use a PreFreeze hook to extend the programming model. For more information, see Programming model extensions. For more information about instance concurrency, see Configure instance concurrency.
Destroying
The instance is destroyed in this phase. You can use a PreStop hook to extend the programming model.
- Idle instances: If an on-demand instance does not receive requests for a period of time, Function Compute automatically reclaims the instance.
- Adjustment of provisioned configurations: Function Compute destroys excess provisioned instances if you reduce the number of provisioned instances in the auto scaling rule.
- Instance exception: Function Compute destroys an instance if the instance encounters an exception during the creation or running process.
What are instance-level events?
An event is a data record that describes a change in the status of a resource. Instances are core resources that are allocated by Function Compute to execute requests. Function Compute dynamically creates and destroys instances to process your requests. In Function Compute, an event is a change in the state of an instance. You can view the events of an instance on the instance details page. Instance-level events allow you to view the lifecycles of instances and locate request execution exceptions that are caused by abnormal instances.
States and change processes of events
Events mark the points in time at which the states of resources change. Each event is associated with at least one definable pre-state and post-state.
The following figure shows the state changes of a function instance and related events.

- Creating: The instance is being created. Function Compute dynamically creates instances based on the number of requests for the function. This state contains the following child states.
- ImagePulling: Your image is being pulled. This state applies to a custom container runtime.
- CodePreparing: Your code package is being pulled and mounted.
- LayerPreparing: Your layer is being pulled and mounted.
- RuntimeInitializing: Your instance is being started and under health check.
- Initializing: The Initializer hook of the function is being executed.
- Finished: Your instance is created.
- Failed: Your instance failed to be created.
- Running: Your instance is running. The instance can process requests when the instance is in this state.
- Destroyed: Your instance is destroyed. The instance is dynamically destroyed based on the number of requests that are sent to the function.
- Error: Your instance cannot process requests as expected and is about to be destroyed.
Event types
Event | Severity | Description | Troubleshooting method |
---|---|---|---|
fc:Instance:Creating | Normal | Function Compute is creating instances to process requests. | N/A |
fc:Instance:PrepareCodeSuccess | Normal | Function Compute has pulled your code package and mounted the package to the instance. Note Function Compute optimizes the loading processes of code packages. The loading process can be completed in a very short period of time under specific conditions. | N/A |
fc:Instance:PrepareCodeFailed | Warning | Function Compute failed to pull and mount your code package. | Join the DingTalk group 11721331 for technical support. |
fc:Instance:PrepareLayerSuccess | Normal | Function Compute has pulled the layer and mounted it to the instance. Note Function Compute optimizes the loading processes of layers. The loading of layers can be completed in a short period of time under specific conditions and can be performed together with code loading. | N/A |
fc:Instance:PrepareLayerFailed | Warning | Function Compute failed to pull and mount the layer. | Join the DingTalk group 11721331 for technical support. |
fc:Instance:PullImageSuccess | Normal | Function Compute has pulled the instance image of your custom container runtime. | N/A |
fc:Instance:PullImageFailed | Warning | Function Compute failed to pull the instance image of your custom container runtime. | Join the DingTalk group 11721331 for technical support. |
fc:Instance:RuntimeInitializationSuccess | Normal | Function Compute has successfully launched your instance and completed the health check. | N/A |
fc:Instance:RuntimeInitializationFailed | Warning | Function Compute detects that your instance failed the health check after the instance is launched. | To resolve the issue, we recommend that view the instance logs and use the methods of error handling in custom runtimes. For more information about how to troubleshoot custom runtime errors, see Troubleshooting. |
fc:Instance:InitializationSuccess | Normal | The Initializer hook is successfully executed. | N/A |
fc:Instance:InitializationFailed | Warning | The Initializer hook failed to be executed. | We recommend that you adjust the logic of the Initializer hook based on the request logs. |
fc:Instance:CreateSuccess | Normal | Your instance is created and is about to process requests. | N/A |
fc:Instance:CreateFailed | Warning | Your instance failed to be built and will be destroyed. | N/A |
fc:Instance:DestroySuccess | Normal | Your instance is destroyed. | N/A |
Query instance-level events
After you enable instance-level metrics, Function Compute collects information about events of instances. The information is sent to the Logstore that you selected when you configured the logging feature. The following section describes how to view the information about instance-level events. For more information about how to enable instance-level metrics, see Enable collection of instance-level metrics.
View instance events in the Function Compute console
- Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
- In the top navigation bar, select a region. On the Services page, click the desired service.
- On the Functions page, click the function that you want to manage. On the function details page, choose .
- View instance events in the Function Compute console
Click the ID of the instance whose events you want to view. In the instance details panel, view the instance-level events.
- View raw event logs in the Log Service console
Find the desired request and click SLS Logs in the Actions column to go to the raw logs page in the Log Service console. On this page, you can filter logs by topic name. The format of a topic name is
FCInstanceEvents:<your-service-name>/<your-function-name>
.
- View instance events in the Function Compute console