On-demand instances are automatically created based on the requests invoked by functions. After instances process requests, the instances are frozen. If the instances no longer process any request in two or five minutes, the instances are reclaimed. Function Compute does not stop instances. If you want to stop instances that are processing requests, refer to this topic to stop the instances.
Manually stop an instance
Specify a timeout period for a function
You can specify a timeout period for a function. When the timeout period elapses, the function automatically exits and an error occurs. For more information, see Manage functions.
Cancel a request on the client
If a function is synchronously invoked, instances of the function no longer process a request if you cancel the request on the client. After all requests are processed and no other requests are allocated to the instances, the instances are automatically reclaimed.
Stop an asynchronous task by using the console or calling an API operation
If the asynchronous task feature is enabled for your function, you can stop an asynchronous task by using the Function Compute console or calling the StopStatefulAsyncInvocation operation. After the task is stopped, the function is automatically reclaimed if the function no longer receives requests in a period of time.
Log on to an instance and run command to stop the instance
If a function is synchronously invoked but the asynchronous task feature is not enabled, you can log on to a desired instance and run the
killcommand to stop its process. This causes the failures of processing requests allocated to the instance. For more information about how to log on to an instance, see CLI-based instance management.
Delete a function
You can delete a function to reclaim instances of the function. In this case, requests allocated to the instances still fail to be processed.