Unlocking Language Limits in Tencent Cloud SCF with Custom Runtime
Tencent Cloud’s Serverless Cloud Function (SCF) removes its language restrictions by providing a Custom Runtime that runs any Linux binary or script as a bootstrap, communicates with SCF via an HTTP API during cold‑start initialization and hot‑start invocations, enabling developers to deploy functions in unsupported languages such as .NET, Rust, Deno, Swift or WebAssembly, as shown by a Deno example.
Serverless Cloud Function (SCF) is Tencent Cloud's FaaS platform that supports multiple languages such as JavaScript, Python, PHP, Java, and Go. In practice, developers encounter limitations like the lack of support for languages such as .NET, Rust, Deno, or C, restrictions on installing additional plugins (e.g., using phpize ), and the inability to upgrade the Java runtime from JDK 8 to newer versions.
To address these issues, Tencent Cloud provides a Custom Runtime (CR) that removes language constraints. CR exposes an HTTP API; the user only needs to send and receive HTTP requests on a designated port to obtain events from SCF and return processing results.
Requirements for using Custom Runtime:
A bootstrap executable (any Linux binary or shell script) that starts the user’s runtime.
An event‑handling function that communicates with SCF via the defined HTTP API.
An optional language‑specific runtime (e.g., for JavaScript, Python, .NET) that can be launched from bootstrap .
The overall architecture consists of an HTTP server running on the SCF side and the user code acting as an HTTP client. Two environment variables, SCF_RUNTIME_API and SCF_RUNTIME_API_PORT , convey the server address to the function.
Cold‑start phase (deployment): SCF extracts the bootstrap program from the user’s zip package, launches it, and the bootstrap performs initialization and notifies SCF via a POST request to /runtime/init/ready .
Hot‑start phase (invocation): The function repeatedly GETs /runtime/invocation/next to fetch events, processes them, and sends the result back with a POST to /runtime/invocation/response . Errors are reported via POST to /runtime/invocation/error .
An example implementation using Deno demonstrates the workflow: the zip package contains a shell bootstrap , the Deno binary, and a demo.ts file that implements the event‑handling logic. The demo shows how the function initializes, polls for events, and posts responses.
The article concludes that Custom Runtime makes SCF language‑agnostic, simplifies development to learning an HTTP API, and enables advanced scenarios such as running Swift or WebAssembly‑based Rust functions on SCF.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.