You can connect to an instance from the Function Compute console or by using Function Compute SDK and manage the instance in the command-line interface (CLI). This topic describes how to connect to an instance from the Function Compute console and run commands on the instance.

Background information

Instances are the execution environments of requests. Function Compute allocates a most appropriate instance for each request for execution and releases the instance when the request is executed. CLI-based instance management allows you to run commands on instances in real runtime environments. For example, you can connect to an instance and check the environment details or collect context information by using tools such as Profiling or Coredump to optimize performance.

Usage notes

  • You can run commands only on live instances, which include long-running provisioned instances and active on-demand instances. If an on-demand instance is idle for the specified period, the instance times out and is released. After the instance is released, you can no longer run commands on the instance.
  • CLI-based instance management requests do not occupy the concurrency quota of an instance. Even if the Single Instance Concurrency parameter is set to 1 for a function, you can invoke the function and manage an instance of the function by using the CLI at the same time.
  • Each command that you run on an instance is considered as a function invocation. If you establish a WebSocket connection to an instance for CLI-based management, the instance stays active until you terminate the connection. You are charged based on the same metering rules for function invocations. If you connect to an instance from the Function Compute console for CLI-based management, the instance is disconnected after it is idle for 10 minutes by default.
Note If you run commands on an instance that is executing an online request, the online environment may be changed and the online request may fail due to the change. The execution of subsequent tasks on the instance is also affected. If requests fail due to CLI-based instance management, the failures are not counted in the service-level agreement (SLA) of Function Compute.

Before you begin

Procedure

  1. https://fcnext.console.aliyun.com/

  2. On the Functions page, click the desired function.
  3. On the Function Details page, click the Instances tab, find the desired instance ID, and then click Connect to Instance in the Actions column.
  4. In the Note message, read the message and click I understand the risks.
    You are redirected to the CLI page of the instance. You can run commands based on your business requirements.
Note You can perform CLI-based operations on instance in the Running state. If the instance is destroyed, you cannot connect to the instance.

References

You can also use Function Compute SDK to perform CLI-based management on instances. For more information about Function Compute SDK, see Supported SDKs.