Introduction
`Function Cloud Hosting is a function hosting model introduced by Cloud Development that supports running functional code on Cloud Hosting, thus it can also be called Cloud Hosting - Function Mode.
`Function Cloud Hosting is essentially a development and operation mode of the Cloud Hosting service, supporting the development and running of functional code on Cloud Hosting without the need to develop a complete service as in traditional container services.
`Function Cloud Hosting can make developing container services as simple as developing cloud functions.
Technical Principle: Function Cloud Hosting = Cloud Hosting + Functions Framework (@cloudbase/functions-framework) + function code. The Functions Framework is also commonly referred to as Runtime, which can load and run cloud functions. Cloud Hosting provides a cloud-based containerized runtime environment.
Q: What problem does Function Cloud Hosting solve?
- Compared to
Cloud Hosting,Function Cloud Hostingoffers a simpler development approach. - Compared to
Cloud Functions,Function Cloud Hostingsupports more scenario capabilities.
`Function Cloud Hosting combines the advantages of both to some extent, allowing developers to choose based on their business scenarios.
Q: How to determine whether function code needs to be deployed to Cloud Hosting?
- If business scenarios require support for features such as
WebSocket long connections,Server-Sent Events (SSE),form submissions,file uploads/downloads,streaming responses,single-instance multi-function, andshared in-memory data between functions,Function Cloud Hostingneeds to be used. - If business scenarios require lower response times and better user experience, it is recommended to use
Function Cloud Hosting. - If functions need to connect to
databasessuch asRedisorMySQL, it is recommended to useFunction Cloud Hosting. - If functions need to interface with
message queuessuch asKafkaorPulsar, it is required to useFunction Cloud Hosting. - If business scenarios require long-running asynchronous task processing, it is recommended to use
Function Cloud Hosting. - If better
log query capabilitiesare needed, it is recommended to useFunction Cloud Hosting. - If you want a better development and debugging experience, it is recommended to use
Function Cloud Hosting. - Currently,
Function Cloud Hostingis still under continuous iteration. If certain features are not yet supported inFunction Cloud Hosting, it is recommended to useCloud Functionsfor development.
The function framework
@cloudbase/functions-frameworkprovides enhanced capability support.
Q: Does Function Cloud Hosting require understanding of Cloud Hosting or containers?
- It is necessary to understand
Cloud Hosting, for example, to decide on selectinginstance specifications,number of instances, etc.Cloud Hostingitself is relatively simple and easy to get started with. - There is no need to understand
containers. Developers do not need to learn the concepts and principles of containers or how to use them. - Overall, compared to
Cloud Functions, it does not require learning and understanding much new content.
Q: How to migrate existing Cloud Function code to Cloud Hosting?
- Existing Cloud Function code can run in the Cloud Hosting environment after minor modifications.
- In addition to modifications to the Cloud Function code itself, the client-side code also requires minor adjustments.
Due to certain differences in runtime mechanisms between the
function framework (@cloudbase/functions-framework)andCloud Functions, some modifications may be required.
Q: Can function code written for Function Cloud Hosting run in other environments?
- Yes, by using the
function framework (@cloudbase/functions-framework), it can run function code in any environment that supportsnode.js. - Supports local running, primarily for development and debugging scenarios
- Supports deployment in traditional host environments, such as cloud server environments
- Supports deployment in container environments, such as
Dockerenvironments
Compared to running in a cloud hosting environment, deployment in other environments requires self-managing build and deployment processes.
For more detailed comparisons, refer to the Comparison with Other Solutions - Cloud Function Comparison document.
Note: Function Cloud Hosting and Cloud Functions differ in invocation methods, invocation paths, and runtime mechanisms. Existing Cloud Function code requires minor modifications to run on Function Cloud Hosting.