Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ FunctionGraph/ User Guide/ Reserved Instance Management (Old)

Reserved Instance Management (Old)

Updated on 2024-11-12 GMT+08:00

What Is a Reserved Instance?

FunctionGraph provides on-demand and reserved instances.

  • On-demand instances are created and released by FunctionGraph based on actual function usage. When receiving requests to call functions, FunctionGraph automatically allocates execution resources to the requests.
  • Reserved instances can be created and released by you as required. After you create reserved instances for a function, FunctionGraph preferentially forwards requests to the reserved instances. If the number of requests exceeds the processing capability of the reserved instances, FunctionGraph will forward the excessive requests to on-demand instances and automatically allocates execution resources to these requests.

    After reserved instances are created for a function, the code, dependencies, and initializer of the function are automatically loaded. Reserved instances are always alive in the execution environment, eliminating the influence of cold starts on your services.

    NOTE:

    To use reserved instances, submit a service ticket to add your account to the whitelist.

You can directly create reserved instances or create them on the function configuration page. Differences between the two modes are described in the following table.

Table 1 Differences between the two modes

Mode

Advantage

Disadvantage

Directly creating reserved instances

You can create a reserved instance with just a few clicks.

Only a fixed number of reserved instances can be created. The reserved instances may be insufficient during peak hours and become idle during off-peak hours.

Creating reserved instances on the function configuration page

You can create different numbers of reserved instances for different periods, preventing waste of reserved instances during off-peak hours and ensuring enough reserved instances during peak hours.

The procedure is complex.

Directly Creating a Fixed Number of Reserved Instances

Ensure that the function, for example, Objective-func, for which you want to create reserved instances already exists on the FunctionGraph console.

  1. Log in to the FunctionGraph console, and choose Functions > Reserved Instances in the navigation pane.
  2. Click Configure Reserved Instance.
  3. Set the following parameters:
    Table 2 Reserved instance information

    Parameter

    Description

    App

    Select the app to which the Objective-func function belongs.

    Function

    Select Objective-func.

    Version

    Select a version of the Objective-func function.

    RI Quantity

    Enter the number of reserved instances to be created.

    To determine how many reserved instances to create, view the number of used instances in the Instance Statistics area or check the usage of the Objective-func function.

  4. Click OK.
    NOTE:

    After creating reserved instances for a function, you can only change the reserved instance quantity.

Creating Reserved Instances on the Function Configuration Page

The number of function instances varies between different periods. To ensure enough reserved instances during peak hours and prevent waste of reserved instances during off-peak hours, you can create a timer for invoking the corresponding function with different number of reserved instances in different periods.

Ensure that the function, for example, Objective-func, for which you want to create reserved instances already exists on the FunctionGraph console.

  1. Return to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
  2. Click Create Function.
  3. Set the following information.

    Parameter

    Description

    Template

    Select Create from scratch.

    Function Name

    Enter a name to identify the function.

    App

    Select default.

    Agency

    Select Use no agency.

    Description

    Enter a description for the function. This parameter is optional.

    Runtime

    Select Python 2.7.

    Handler

    Enter index.handler.

    Code Entry Mode

    When creating a function, select Default code. On the Configuration tab page, select Edit code inline and enter the following code:

    # -*- coding:utf-8 -*-
    import json
    import requests
    def handler (event, context):
        domainId = "https://{Endpoint}"
        url = "/v2/{project_id}/fgs/functions/{func-urn}/reservedinstances"
        token = context.getToken()
        requrl = domainId + url
        headerdata = {"Content-Type":"application/json","x-auth-token":token}
        r = requests.put(requrl, data=event["user_event"], headers=headerdata,verify=False)
        return r.json

    Replace the following parameters with the actual values:

    • Endpoint: Endpoint of the Objective-func function. For details, see Regions and Endpoints.
    • project_id: ID of the project to which the Objective-func function belongs. For details, see Obtaining a Project ID.
    • func-urn: URN of the Objective-func function.
  4. Click Create Function.
  5. On the Configuration tab page, click Create Agency.
  6. Create an agency and grant it the FunctionGraph User permission. For details, see Configuring Agency Permissions.
  7. On the Configuration tab page, select the agency created in 6, and click Save.
  8. On the Triggers tab page, click Create Trigger.
  9. Set the following information.

    Parameter

    Description

    Trigger Type

    Select Timer.

    Timer Name

    Enter a name to identify the timer.

    Rule

    Select Cron expression and enter a cron expression as required.

    Enable Trigger

    By default, this function is enabled. Retain the default setting.

    Additional Information

    Enter the number of reserved instances required in different periods based on the trigger rule.

    Figure 1 Creating a timer trigger

    Figure 1 shows a timer trigger that requests FunctionGraph to create two reserved instances every 3 minutes.

  10. Click OK.

    After trigger creation, different numbers of reserved instances will be created for the Objective-func function in different periods based on the trigger rule.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback