doc-exports/docs/fg/umn/functiongraph_01_0201.html
Chen, Junjie dac566cf2f FG UMN 20230725 version
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: Chen, Junjie <chenjunjie@huawei.com>
Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
2024-04-03 10:30:56 +00:00

50 lines
7.0 KiB
HTML

<a name="functiongraph_01_0201"></a><a name="functiongraph_01_0201"></a>
<h1 class="topictitle1">Configuring Initialization</h1>
<div id="body32001227"><div class="section" id="functiongraph_01_0201__en-us_topic_0000001251907920_section198581016111710"><h4 class="sectiontitle">Overview</h4><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p188990435268">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.</p>
</div>
<div class="section" id="functiongraph_01_0201__en-us_topic_0000001251907920_section435553192518"><h4 class="sectiontitle">Scenario</h4><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p33302152611">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.</p>
</div>
<div class="section" id="functiongraph_01_0201__en-us_topic_0000001251907920_section876024412110"><h4 class="sectiontitle">Prerequisites</h4><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p2712248205616">You have created a function.</p>
</div>
<div class="section" id="functiongraph_01_0201__en-us_topic_0000001251907920_section5481134641018"><h4 class="sectiontitle">Initializing a Function</h4><ol id="functiongraph_01_0201__en-us_topic_0000001251907920_ol182196394126"><li id="functiongraph_01_0201__en-us_topic_0000001251907920_li12191539131216"><span>Log in to the FunctionGraph console. In the navigation pane, choose <strong id="functiongraph_01_0201__en-us_topic_0000001251907920_en-us_topic_0000001251907924_b033610517502">Functions</strong> &gt; <strong id="functiongraph_01_0201__en-us_topic_0000001251907920_en-us_topic_0000001251907924_b183361950502">Function List</strong>.</span></li><li id="functiongraph_01_0201__en-us_topic_0000001251907920_li19316816141419"><span>Click the function to be configured to go to the function details page.</span></li><li id="functiongraph_01_0201__en-us_topic_0000001251907920_li10690193113417"><span>Click the <strong id="functiongraph_01_0201__en-us_topic_0000001251907920_b620012818533">Configuration</strong> tab and choose <strong id="functiongraph_01_0201__en-us_topic_0000001251907920_b84341811537">Advanced Settings</strong>.</span><p><div class="fignone" id="functiongraph_01_0201__en-us_topic_0000001251907920_fig381414113308"><span class="figcap"><b>Figure 1 </b>Enabling initialization</span><br><span><img id="functiongraph_01_0201__en-us_topic_0000001251907920_image1881517173010" src="en-us_image_0000001678920797.png"></span></div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_0201__en-us_topic_0000001251907920_table183871514153613" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter configuration</caption><thead align="left"><tr id="functiongraph_01_0201__en-us_topic_0000001251907920_row33874140368"><th align="left" class="cellrowborder" valign="top" width="22.189999999999998%" id="mcps1.3.4.2.3.2.2.2.3.1.1"><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p1638871433612">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="77.81%" id="mcps1.3.4.2.3.2.2.2.3.1.2"><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p1038811411360">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="functiongraph_01_0201__en-us_topic_0000001251907920_row16388014153614"><td class="cellrowborder" valign="top" width="22.189999999999998%" headers="mcps1.3.4.2.3.2.2.2.3.1.1 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p17388181416366">Initialization</p>
</td>
<td class="cellrowborder" valign="top" width="77.81%" headers="mcps1.3.4.2.3.2.2.2.3.1.2 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p123881914163610">Enable initialization if needed.</p>
</td>
</tr>
<tr id="functiongraph_01_0201__en-us_topic_0000001251907920_row1238841473616"><td class="cellrowborder" valign="top" width="22.189999999999998%" headers="mcps1.3.4.2.3.2.2.2.3.1.1 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p63881114103620">Initialization Timeout (s)</p>
</td>
<td class="cellrowborder" valign="top" width="77.81%" headers="mcps1.3.4.2.3.2.2.2.3.1.2 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p755152019326">Maximum duration the function can be initialized. Set this parameter if you enable function initialization.</p>
<p id="functiongraph_01_0201__en-us_topic_0000001251907920_p1668917883618">The value ranges from 1s to 300s.</p>
</td>
</tr>
<tr id="functiongraph_01_0201__en-us_topic_0000001251907920_row1138861473610"><td class="cellrowborder" valign="top" width="22.189999999999998%" headers="mcps1.3.4.2.3.2.2.2.3.1.1 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p4388191463619">Initializer</p>
</td>
<td class="cellrowborder" valign="top" width="77.81%" headers="mcps1.3.4.2.3.2.2.2.3.1.2 "><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p12803236193913">You can enable function initialization on the <strong id="functiongraph_01_0201__en-us_topic_0000001251907920_b15288171712553">Configuration</strong> 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 <em id="functiongraph_01_0201__en-us_topic_0000001251907920_i10605131011321">[file name]</em>.<em id="functiongraph_01_0201__en-us_topic_0000001251907920_i460521012324">[initialization function name]</em>.</p>
<div class="note" id="functiongraph_01_0201__en-us_topic_0000001251907920_note370118172517"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="functiongraph_01_0201__en-us_topic_0000001251907920_p97017819255">This parameter is not required if function initialization is disabled.</p>
</div></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="functiongraph_01_0201__en-us_topic_0000001251907920_note1712183194118"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_01_0201__en-us_topic_0000001251907920_ul14809557133915"><li id="functiongraph_01_0201__en-us_topic_0000001251907920_li158081157103920">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 <em id="functiongraph_01_0201__en-us_topic_0000001251907920_i18525417133210">[file name]</em>.<em id="functiongraph_01_0201__en-us_topic_0000001251907920_i195311417143217">[initialization function name]</em>.</li><li id="functiongraph_01_0201__en-us_topic_0000001251907920_li10809205713392">For details about the function code configuration, see <a href="functiongraph_01_0152.html#functiongraph_01_0152">Creating a Deployment Package</a>.</li></ul>
</div></div>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_01_0300.html">Configuring Functions</a></div>
</div>
</div>