Best Practice

Last updated: 2020-02-27 13:30:46

Based on the features of Serverless Cloud Function (SCF), we recommend that you:

  • Write function code in a stateless style to ensure that your code does not perform any state maintenance. Both local storage and memory results may be lost, so services such as COS and Redis/Memcached should be used to cache intermediate information and land the final calculation results.
    Instantiate any objects that may be reused (such as database connection, etc.) Other than execution methods.
    Configure + rx (read and execute) permission to your file in the uploaded ZIP to ensure a successful execution of code.
    Maximize the use of log/print statements in the code to provide sufficient information for debugging.
    Users can use external code management services (such as Git, etc) for the purpose of version and audit management of core codes, to ensure the completeness of code (version management feature will be available soon).

Welcome to subscribe [ Serverless Technology column] learn more about the latest practices and Tencent Cloud Serverless trends.

In the following specific practice, most of the functions are deployed in the form of template functions. Users can download the code to analyze and learn. Both the template function and the code support the download operation.

Was this page helpful?

Was this page helpful?

  • Not at all
  • Not very helpful
  • Somewhat helpful
  • Very helpful
  • Extremely helpful
Send Feedback