All Products
Search
Document Center

Function Compute:Principles

Last Updated:Apr 01, 2026

In a custom runtime, your code package (ZIP format) is an HTTP server program. Function Compute starts that HTTP server during a cold start and routes all incoming requests through it.

How it works

When Function Compute performs a cold start, it runs the Startup Command and Startup Parameter you configured to launch your HTTP server. The HTTP server then takes over all requests from Function Compute.

If you do not configure a startup command or parameters, Function Compute starts the HTTP server from /code/bootstrap by default.

The cold start completes in two stages:

  1. Platform preparation — Function Compute initializes the execution environment and prepares to launch your code.

  2. HTTP server startup — Function Compute runs your startup command. The HTTP server must be ready within 120 seconds.

Configure the startup command

The startup command is defined in customRuntimeConfig:

FieldDescription
commandThe executable to run
argsArguments passed to the executable

Function Compute concatenates command and args to form the complete startup command.

Suppose your code package is named function.zip. The following examples show the package structure and the corresponding customRuntimeConfig for each runtime.

Java 8 or Spring Boot

.
└── demo.jar
customRuntimeConfig:
  command:
    - java
  args:
    - '-jar'
    - 'demo.jar'

Python 3.7

.
└── server.py
customRuntimeConfig:
  command:
    - python
  args:
    - 'server.py'

Node.js 10

.
└── server.js
customRuntimeConfig:
  command:
    - node
  args:
    - 'server.js'

PHP 7.4

.
└── server.php
customRuntimeConfig:
  command:
    - php
  args:
    - 'server.php'

HTTP server requirements

Configure your HTTP server to meet the following requirements. Violating any of these causes Function Compute to reject or fail the connection.

RequirementDetailsError if violated
Bind to the correct addressListen on 0.0.0.0:CAPort or *:CAPort. Do not use 127.0.0.1:CAPort.FunctionNotStarted — connection refused
Match the configured portThe server's listening port must match the CAPort value in your function configurations. The default is 9000. To use a different port (for example, 8080), set CAPort to 8080 in your function configurations.FunctionNotStarted — ping failed
Enable keep-aliveEnable keep-alive mode and set the connection timeout to at least 24 hours (the maximum function execution duration).Connections drop mid-execution
Start within 120 secondsThe HTTP server must be ready to accept connections within 120 seconds of launch.Startup fails

Example: keep-alive configuration (Node.js with Express)

const server = app.listen(PORT, HOST);
server.timeout = 0;          // never timeout
server.keepAliveTimeout = 0; // keep-alive, never timeout

Error reference: binding to 127.0.0.1

If the HTTP server listens on 127.0.0.1 instead of 0.0.0.0, Function Compute cannot reach it and returns:

{
  "ErrorCode": "FunctionNotStarted",
  "ErrorMessage": "TheCA'shttpservercannotbestarted:ContainerStartDuration:25000000000.PingCAfaileddueto:dialtcp21.0.XX.XX:9000:getsockopt:connectionrefusedLogs:2019-11-29T09:53:30.859837462ZListeningonport9000"
}