This problem is usually caused by the fact that the dependency file for code execution is not uploaded to the cloud environment. You can troubleshot as follows:
UTC (GMT+0) is used in the SCF operating environment, which is 8 hours behind Beijing time.
You can use a time processing library or code package in your programming language to identify the UTC time zone and convert it to Beijing time (GMT+8). You can also set the
TZ=Asia/Shanghai environment variable to specify the time zone.
SCF function has a temporary disk space of 500 MB (
/tmp) during execution. You can perform read and write operations in this space or create subdirectories while executing the code, but data written in this space will not be retained after the function is executed.
- The temporary disk spaces of different instances are isolated, i.e., each instance has its own independent temporary space.
- In the operating environment, all directories are read-only except for
If data is written to the
/tmp directory continuously and the instance is constantly used due to frequent invocations, the directory may be full and data cannot be written into.
In this case, check the writes in the directory and use codes to delete obsolete temporary files to free up space.
API Gateway parses the returned result from SCF into JSON format by default. To solve this problem, you can select integration response in function configuration as instructed in Integration response and passthrough response. Note that after integration response is enabled, the required data structure needs to be returned.
Yes. For more information, see Sub-user and Authorization.
The function can be triggered directly by calling the
Invoke API of SCF. The owner of the function or an authorized account can call this API directly.
Yes. There is a short window period of less than 1 minute in general when the function is updated, during which the request will be implemented by either the old or new function code.
In case of failure, a function that makes sync invocations will return the exception information, while a function that makes async invocations will automatically retry. For more information, see Error Types and Retry Policies.
Yes. You can use general programming language and operating system features, such as creating additional threads and processes. Resources allocated to the function, including memory, execution duration, disk, and network, are shared by the threads or processes it uses.
We try not to impose restrictions on normal activities at the programming language and operating system levels, but certain activities such as inbound network connection are disabled.
API Gateway can be used to this end. Configure the backend of API Gateway as a function and then call the gateway API to trigger the function. For detailed directions, see Creating Triggers and Overview.
Currently, SCF functions can be triggered by manual triggers (APIs), timer triggers, COS, CMQ, and API Gateway, and more triggering methods will be supported soon.
Currently, it supports Python 2.7 and 3.6, Node.js 6.10, 8.9, 10.15, and 12.16, Java 8, PHP 5 and 7, Go, and Custom Runtime. More programming languages will be supported soon.
No. SCF manages the computing infrastructure on your behalf.
Each function runs in its own unique environment and has its own resources and file system. SCF uses the same technology as CVM to provide security and isolation at the infrastructure and execution levels.
Yes. When you create or modify a function, select VPC configuration and deploy the function in the same VPC as the CVM or TencentDB instance.
To improve performance, SCF will retain your function instance for a certain period of time and reuse it for subsequent requests. However, do not rely on this reuse.
Keeping the statelessness of the function allows the function to launch as many instances as needed to meet the requested rate.
SCF provides a logging feature. Each invocation will output its log to the logs window in the console. The log records the resources consumed by the function during each use, the log in the code, and the platform invocations. You can easily insert troubleshooting log statements into your code.
A possible reason is that the function's execution method cannot find the corresponding executable file or function entry in the zip package, because an outer folder is compressed together.
The execution method format is
a is the name of the
.py file, and
b is the method name in the code.
If a file named
a.py cannot be found in the root directory of the unzipped folder, the system will prompt that "The function code cannot be displayed. The file name specified by the execution method cannot be found in the code zip package".
For example, if a folder structure is as follows:
--RootFolder ----SecondFolder ------a.py ------thirdfolder --------sth.json
If you compress
SecondFolder when creating the zip package, the above error will occur; instead, you should only compress
Set the timeout period to a larger value (up to 900) and test the function again. If it still times out, check whether there are excessive input data and computation, loops that cannot be jumped out, or prolonged sleeps in the log of your code.
You don't need to care about function scaling as the SCF platform will automatically do so on your behalf. Whenever a function request is received, SCF will quickly locate the free capacity and execute your code. Since your code is stateless, as many instances as needed can be launched without lengthy delays in deployment and configuration.
You can select the amount of memory allocated to a function, and the CPU and other resources will be allocated proportionally. For example, if you select 256 MB of memory, the CPU allocated to the function will be approximately twice that allocated for 128 MB of memory.
Yes. You can add your own code repository to the function code and upload it to the platform as a zip package.
A common reason is that the function concurrency exceeds the quota limit. You can calculate the required amount of function concurrency with the formula "function concurrency = QPS (number of requests per second) * function execution duration (in seconds)".
For example, if QPS = 100 and function execution duration = 100 ms, then the actual required function concurrency will be 100 * 0.1 = 10. If the result exceeds the quota limit, you can submit a ticket to increase the limit.
There are overdue payments in your account. Top up and try again.
SCF_QcsRole role is required for creating a function. Log in to the SCF console with your root account and follow the instructions to complete the authorization.
SCF_QcsRole on the Role page in the CAM console and confirm whether it has been associated with the preset policy
QcloudAccessForScfRole, and if not, click Add Policy to associate
QcloudAccessForScfRole and try again.
DemoIdwhen creating a function with a template?
Select Template as the creation method when creating a function in the SCF console, select the template you want to use, click View Details in the top-right corner of the template, and click Click to download template function on the template details page. The template code will be downloaded to the local system with the name
DemoIdof the same function template varies by region. Pay attention to the region when getting the