doc-exports/docs/fg/umn/functiongraph_01_0310.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

25 lines
8.8 KiB
HTML

<a name="functiongraph_01_0310"></a><a name="functiongraph_01_0310"></a>
<h1 class="topictitle1">Configuring Dynamic Memory</h1>
<div id="body32001227"><div class="section" id="functiongraph_01_0310__en-us_topic_0000001298786849_section129643713421"><h4 class="sectiontitle">Overview</h4><p id="functiongraph_01_0310__en-us_topic_0000001298786849_p19560163914210">By default, a function is bound with only one resource specification. After enabling dynamic memory, you can configure a specification for request processing. If no specification is configured, the default one is used.</p>
</div>
<div class="section" id="functiongraph_01_0310__en-us_topic_0000001298786849_section2691164974210"><h4 class="sectiontitle">Scenario</h4><p id="functiongraph_01_0310__en-us_topic_0000001298786849_p20497132411423">Take video transcoding as an example. The size of a video file ranges from MB to GB. Different encoding formats and resolutions require different computing resources. To ensure performance, you usually need to configure a large resource specification, which however will result in a waste during low-resolution video (such as short video) processing. To solve this problem, implement the transcoding service with two functions: metadata obtaining and transcoding. Configure a specification for the transcoding function according to the metadata information to minimize the resources and cost.</p>
</div>
<div class="section" id="functiongraph_01_0310__en-us_topic_0000001298786849_section35341622254"><h4 class="sectiontitle">Prerequisites</h4><p id="functiongraph_01_0310__en-us_topic_0000001298786849_p135031815251">You have created a function according to <a href="functiongraph_01_0153.html#functiongraph_01_0153">Creating a Function from Scratch</a>.</p>
</div>
<div class="section" id="functiongraph_01_0310__en-us_topic_0000001298786849_section3121102002610"><h4 class="sectiontitle">Procedure</h4><ol id="functiongraph_01_0310__en-us_topic_0000001298786849_ol529717123619"><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li2081916375575"><span>Log in to the FunctionGraph console, choose <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b9177553113113">Functions</strong> &gt; <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b12108145823120">Function List</strong> in the navigation pane, and click the name of the created function.</span><p><div class="fignone" id="functiongraph_01_0310__en-us_topic_0000001298786849_fig8262195512710"><span class="figcap"><b>Figure 1 </b>Selecting a created function</span><br><span><img id="functiongraph_01_0310__en-us_topic_0000001298786849_image326225582718" src="en-us_image_0000001298507537.png"></span></div>
</p></li><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li98606414595"><span>On the function details page, choose <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b176538548412">Configuration</strong> &gt; <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b972995917410">Advanced Settings</strong> and enable <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b4981126857">Dynamic Memory</strong>.</span></li><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li193829982310"><span>Call the synchronous or asynchronous function execution API, add <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b7467165313424">X-Cff-Instance-Memory</strong> to the request header, and set the value to <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b13899123518438">128</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b7732173916436">256</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1365104234318">512</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b466894474318">768</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b9645114618436">1024</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b5576248114314">1280</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b127231051174318">1536</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b3880155394311">1792</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b01725611434">2048</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b174251658124311">2560</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1558850104413">3072</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b549515314443">3584</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b7618963448">4096</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b194611820062">8192</strong>, or <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b17220823362">10240</strong>.</span><p><p id="functiongraph_01_0310__en-us_topic_0000001298786849_p117233237383">The following describes how to call an API using Postman. Add <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1593753620415">X-Cff-Instance-Memory</strong> to <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1930634220415">Headers</strong> and set the value to <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b17555058104119">512</strong>. If the API is called successfully, error code 200 will be returned.</p>
<div class="fignone" id="functiongraph_01_0310__en-us_topic_0000001298786849_fig1117193319460"><span class="figcap"><b>Figure 2 </b>Adding a request header and calling the function</span><br><span><img id="functiongraph_01_0310__en-us_topic_0000001298786849_image141720333465" src="en-us_image_0000001252067312.png"></span></div>
<div class="note" id="functiongraph_01_0310__en-us_topic_0000001298786849_note139701040195513"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="functiongraph_01_0310__en-us_topic_0000001298786849_ul193231845565"><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li16703121195215">If <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b154651833143213">Dynamic Memory</strong> is not enabled, the memory size set when the function is created will be used by default.</li><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li4323947565">If <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b16856182403318">Dynamic Memory</strong> is enabled but the memory value has not been set, the memory size set when the function is created will be used by default. If the API is called successfully, error code 200 will be returned.</li><li id="functiongraph_01_0310__en-us_topic_0000001298786849_li76381425145417">If <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1630618173613">Dynamic Memory</strong> is enabled but the memory value is not <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b6261176377">128</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b12153171612373">256</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b51864185374">512</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1306820163714">768</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b194530237372">1024</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b102461128193719">1280</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b2848311375">1536</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b17706203343714">1792</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b13826163523710">2048</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1596163863711">2560</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b17473134063713">3072</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b864410424377">3584</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b213714515372">4096</strong>, <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b1108366615">8192</strong>, or <strong id="functiongraph_01_0310__en-us_topic_0000001298786849_b007361366">10240</strong>, error code FSS.0406 will be returned when the API is called. You only need to reset the memory value.<div class="fignone" id="functiongraph_01_0310__en-us_topic_0000001298786849_fig1179019241114"><span class="figcap"><b>Figure 3 </b>Invocation failure</span><br><span><img id="functiongraph_01_0310__en-us_topic_0000001298786849_image12790224171113" src="en-us_image_0000001251748292.png"></span></div>
</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>