Instance-level events
Instance-level events give you visibility into the full lifecycle of a function instance — from creation through destruction. Use events to understand what happened during each lifecycle phase and to pinpoint the root cause when a request fails or takes longer than expected.
How instance lifecycle works
Function Compute dynamically creates and destroys instances based on incoming request volume. Each instance passes through three phases:
Creating — Function Compute sets up the instance: pulling code, layers, or images; starting the runtime; and running the initializer hook.
Invoke — The instance processes function invocations. Between invocations, the instance is frozen and does not incur charges.
Destroy — The instance is torn down. Function Compute runs the PreStop callback before destruction.
Function Compute records the time of each significant state change within these phases as an instance-level event. Events are visible on the instance details page in the console and are stored in the Logstore you configure for instance-level metrics.
Instance lifecycle phases
Creating phase
When an instance is created, Function Compute completes the following steps in sequence:
Instance Create — Loads your code package, pulls layers, or pulls the container image (for custom container runtimes). Then starts the instance process.
Runtime Init — Starts the runtime and runs a health check.
Init Hook — Runs your initializer hook, if configured.
Instance creation is triggered in two scenarios:
Elastic scale-out: A new invocation arrives and all existing instances are busy, so Function Compute creates a new instance to handle it. Elastic scale-out may cause cold starts. See Best practices for optimizing Function Compute cold starts for ways to reduce cold start latency.
Minimum instance count increase: When you raise the minimum instance count from 0 to 1 or more, Function Compute immediately creates the required instances. These instances may remain idle for some time before receiving their first invocation. See Configure elastic policy for minimum instance count.
Invoke phase
Once running, an instance invokes your function handler to process requests. Concurrency behavior differs by runtime type:
Built-in runtimes: Each instance handles one request at a time.
Custom runtimes and custom container runtimes: A single instance can handle multiple concurrent requests. Enable this by configuring single-instance concurrency.
Function Compute bills only for actual request and callback execution time. See Billing details.
Instance freeze mechanism
When no requests are pending, Function Compute freezes the instance. Background processes, threads, and coroutines stop running — asynchronous log writes may not complete. The instance is unfrozen when the next request arrives.
Freezing occurs at two points:
After the Creating phase completes, before the first invocation.
After each invocation ends, before the next invocation begins.
Destroy phase
Destruction is triggered in three scenarios:
Instance shallow hibernation (formerly idle): The instance receives no invocations for a specific period and is automatically reclaimed.
Minimum instance count reduction: When you lower the minimum instance count, excess instances are immediately destroyed.
Instance failure: If the instance fails during creation or execution, Function Compute destroys it.
During destruction, Function Compute runs the PreStop callback first, giving your code a chance to flush state or close connections before the instance is removed.
Instance statuses
The following table lists the statuses a function instance can be in and the sub-statuses within the Creating phase.
| Status | Description |
|---|---|
| Creating | Instance is being created. |
| ↳ ImagePulling | Container image is being pulled (custom container runtimes only). |
| ↳ CodePreparing | Code package is being pulled and mounted. |
| ↳ LayerPreparing | Layers are being pulled and mounted. |
| ↳ RuntimeInitializing | Instance is starting and undergoing the health check. |
| ↳ Initializing | Initializer hook is running. |
| ↳ Finished | Instance created successfully. |
| ↳ Failed | Instance creation failed. |
| Running | Instance is running and processing invocations. |
| Destroyed | Instance has been destroyed. |
| Error | Instance cannot process invocations and is about to be destroyed. |
The following diagram shows how these statuses transition and which events mark each transition.
Event types
The following table lists all instance-level events. Warning-level events indicate a problem that requires action.
| Event name | Event code | Level | What it means | What to do |
|---|---|---|---|---|
| Instance creating | fc:Instance:Creating | Normal | Function Compute has started creating an instance for your request. | — |
| Code loaded | fc:Instance:PrepareCodeSuccess | Normal | Code package pulled and mounted successfully. Function Compute applies optimizations that can make this step very fast. | — |
| Code loading failed | fc:Instance:PrepareCodeFailed | Warning | Failed to pull or mount the code package. | Join the DingTalk user group (Group ID: 64970014484) for support. |
| Layer loaded | fc:Instance:PrepareLayerSuccess | Normal | Layers pulled and mounted successfully. Under certain conditions, this occurs at the same time as code loading. | — |
| Layer loading failed | fc:Instance:PrepareLayerFailed | Warning | Failed to pull or mount layers. | Join the DingTalk user group (Group ID: 64970014484) for support. |
| Image ready | fc:Instance:PullImageSuccess | Normal | Container image pulled successfully (custom container runtimes only). | — |
| Image preparation failed | fc:Instance:PullImageFailed | Warning | Failed to pull the container image. | Join the DingTalk user group (Group ID: 64970014484) for support. |
| Instance startup successful | fc:Instance:RuntimeInitializationSuccess | Normal | Instance started and passed the health check. | — |
| Instance startup failure | fc:Instance:RuntimeInitializationFailed | Warning | Instance failed the health check after startup. | Check instance logs and troubleshoot using the Error handling guide for custom runtime errors. |
| Initializer execution successful | fc:Instance:InitializationSuccess | Normal | Initializer hook ran successfully. | — |
| Initializer execution failed | fc:Instance:InitializationFailed | Warning | Initializer hook failed. | Review the request logs and adjust your initializer hook logic. |
| Instance creation successful | fc:Instance:CreateSuccess | Normal | Instance is ready to process invocations. | — |
| Instance creation failed | fc:Instance:CreateFailed | Warning | Instance creation failed and the instance is being destroyed. | — |
| Instance destroyed | fc:Instance:DestroySuccess | Normal | Instance has been destroyed. | — |
View instance-level events
Prerequisites
Before you begin, ensure that you have:
Enabled instance-level metrics. See Configure instance-level metrics. Event data is delivered to the Logstore you specify when configuring instance-level metrics.
View events in the Function Compute console
Log on to the Function Compute console. In the left navigation pane, choose Function Management > Function.
In the top menu bar, select a region. On the Function page, click the target function.
On the function details page, click the Logs tab, then click the Invocation Requests tab.
Click the instance ID of the target request. The instance details panel opens and displays the instance-level events for that instance.
View raw event logs in Simple Log Service
Follow steps 1–3 above to reach the Invocation Requests tab.
In the Actions column of the target request, click Advanced Logs. You are redirected to the Simple Log Service console.
Filter logs by topic name. Topic names follow the format
FCInstanceEvents:/<functionname>.