Configuring Huawei Cloud Function Graph requires navigating the console to define runtime environments, memory limits, and execution roles. This guide walks you through creating a function, setting essential parameters like timeout and handler, and deploying your code without relying on unverified defaults or external platform specifics.
Accessing the Function Graph Console
To begin configuration, log in to the Huawei Cloud Management Console and navigate to the FunctionGraph service. Ensure you are in the correct region where your resources reside. From the left-hand navigation pane, select Functions under the Service section. Click the Create Function button located at the top right of the list view. This action opens the configuration wizard where all critical settings are defined before deployment.
Selecting Runtime and Basic Settings
The first step involves choosing the programming language runtime. Huawei Cloud supports Python, Java, Go, Node.js, C++, and custom container images. Select the appropriate runtime for your application logic. Next, provide a unique function name that follows your organization's naming conventions. You must also specify the package type as either Code Package or Image. If using Code Package, you can upload a ZIP file directly from your local machine or paste inline code. For image-based functions, provide the full path to the container image in a supported registry.
Set the initial memory allocation carefully. While default values exist, they may not suit high-throughput workloads. Adjust the memory size according to your function's computational needs. Higher memory allocations often correlate with proportional CPU power, which can improve performance for complex tasks. Define the timeout duration based on expected execution time. Avoid excessively long timeouts to prevent unnecessary resource consumption during idle periods.
Defining the Handler Entry Point
The handler parameter specifies the entry point of your function. It typically follows the format
filename.method_name. For example, if your main module is named
main.py and contains a function called
handler, the entry should be
main.handler. Incorrect handler definitions result in invocation failures. Verify this setting matches your code structure precisely before proceeding.
Configuring Advanced Execution Parameters
Beyond basic setup, several advanced options impact reliability and security. The concurrency level determines how many instances of your function run simultaneously. Setting this too low may cause throttling under load, while setting it too high might exceed account quotas. Start with a moderate value and monitor usage metrics via Cloud Eye.
Enable logging by selecting the appropriate log group and log stream. This ensures that standard output and error streams are captured for debugging. Review the IAM agency settings to grant necessary permissions. The function needs an agency role to access other cloud services like Object Storage Service (OBS) or Data Lake Insight (DLI). Without proper agency assignment, calls to these services will fail with authorization errors.
Testing and Deployment
After configuring all parameters, click Save to store the function definition. Use the Test tab within the FunctionGraph interface to invoke the function locally. Provide sample input data in JSON format if your function expects arguments. Observe the execution result and check the logs for any exceptions. Successful test runs confirm that the runtime environment and handler are correctly configured.
For production deployment, consider integrating with API Gateway or Event Notifications Service. These services trigger function execution based on HTTP requests or system events. Configure triggers in the Triggers tab by selecting the source service and mapping event types. This decouples your function from direct user interaction, enabling scalable serverless architectures.
Monitoring and Optimization
Regularly review function performance using Cloud Eye dashboards. Key metrics include invocation count, average latency, and error rates. High error rates may indicate issues with dependencies or insufficient memory. Optimize cold start times by keeping the runtime warm or using provisioned concurrency if available. Keep your code packages small to reduce initialization overhead. Remove unused libraries and compress assets effectively.
For teams managing multiple environments, utilize versioning features. Create new versions after testing changes in staging. Route traffic between versions using alias configurations to manage rollouts smoothly. This approach minimizes risk during updates and allows for quick rollback if issues arise.
Security Best Practices
Apply the principle of least privilege when assigning IAM agencies. Grant only the specific permissions required for the function to operate. Avoid using root credentials or overly broad roles. Rotate access keys regularly if your function interacts with other services programmatically. Enable VPC connectivity if your function accesses private resources. This isolates traffic and prevents unauthorized network access.
Related articles:
Configuring Reverse Proxy with IP Address on Google Cloud Platform for Hidden Minecraft Server provides insights into network isolation strategies relevant to secure function deployments.
Maintaining Cloud-to-Cloud Backup outlines general principles for reliable data handling that apply to serverless state management.
Frequently Asked Questions
How do I resolve permission denied errors?
Check the IAM agency attached to your function. Ensure the agency has policies granting access to the specific resources your code interacts with. Verify that the resource names in your code match those in the target service exactly.
What causes cold starts in Function Graph?
Cold starts occur when a new instance of the function is initialized due to inactivity. They are influenced by the runtime language and package size. Using faster runtimes or reducing package dependencies can mitigate delay.
Can I use custom containers?
Yes, Huawei Cloud supports custom container images. You must provide the image URI and ensure it includes a valid executable entry point compatible with the FunctionGraph runtime specifications.
How is billing calculated for Function Graph?
Billing is based on the number of invocations, allocated memory, and execution duration. There are no charges for idle time unless provisioned concurrency is enabled. Monitor usage to optimize costs effectively.
What happens if my function exceeds the timeout limit?
The invocation fails and returns a timeout error. The function does not complete its task, and any partial side effects may remain depending on atomicity guarantees. Increase the timeout setting if the operation legitimately requires more time.