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.
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.
You have created a function.
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. |