Configuring Initialization
Overview
The initializer of a function is executed after an instance is started. The instance starts to process requests only after the initializer is executed. The initializer is executed only once during the lifecycle of a function instance.
Scenario
The service logic shared by multiple requests can be implemented in the initializer to reduce the latency. For example, the logic of loading a deep learning model with large specifications or building a connection pool for databases.
Prerequisites
You have created a function.
Initializing a Function
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the function to be configured to go to the function details page.
- Click the Configuration tab and choose Advanced Settings.
Figure 1 Enabling initialization
Table 1 Parameter configuration Parameter
Description
Initialization
Enable initialization if needed.
Initialization Timeout (s)
Maximum duration the function can be initialized. Set this parameter if you enable function initialization.
The value ranges from 1s to 300s.
Initializer
You can enable function initialization on the Configuration tab page. The initializer must be named in the same way as the handler. For example, for a Node.js or Python function, set an initializer name in the format of [file name].[initialization function name].
NOTE:This parameter is not required if function initialization is disabled.
- Set the initializer in the same way as the handler. For example, for a Node.js or Python function, set an initializer name in the format of [file name].[initialization function name].
- For details about the function code configuration, see Creating a Deployment Package.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot