All Products
Search
Document Center

Function Compute:Overview

Last Updated:Jun 11, 2024

This topic describes custom runtimes in which you can write functions in Function Compute.

Background

Custom runtimes allow you to customize runtime environments. In a custom runtime, you can create an exclusive function execution environment based on your business requirements. The following items list common scenarios:

  • Customize an individualized programming language, such as Rust.

  • Customize a runtime of a specified version of a programming language, such as Node.js 16.

Container environments

The following table shows the container environments supported by custom runtimes.

Runtime

Identifier

Operating system

Architecture

Custom runtime (Debian10)

custom.debian10

Debian 10

x86_64

Custom Runtime

custom

Debian 9

x86_64

Custom runtime (Debian10)

  • User permissions: Functions must be executed by root users.

  • Directory permissions: Data can be written to any directory.

  • Code location in the container: /code.

Custom Runtime

  • User permissions

    • If functions are created at and after 00:00:00 December 1, 2021, the functions must be executed by root users.

    • If functions are created before 00:00:00 December 1, 2021, the functions must be executed by non-root users.

  • Directory permissions

    • If functions are created at and after 00:00:00 December 1, 2021, data can be written to any directory.

    • If functions are created before 00:00:00 December 1, 2021, data can be written to only the /tmp directory.

  • Code location in the container: /code.

Environment information

Custom runtime (Debian10)

The following programming languages are built into Debian 10-based custom runtimes. You can create custom runtimes of the following languages without the need to install third-party interpreters or configure layers:

The following table describes the details. For some programming languages, environment variables must be configured.

Programming language

Installation directory

Version

Environment variable

Node.js 20

/var/fc/lang/nodejs20

v20.10.0

PATH=/var/fc/lang/nodejs20/bin:$PATH

Node.js 18

/var/fc/lang/nodejs18

v18.19.0

PATH=/var/fc/lang/nodejs18/bin:$PATH

Python 3.10

/var/fc/lang/python3.10

3.10.9

PATH=/var/fc/lang/python3.10/bin:$PATH

Python 2.7

Default installation directory

2.7.16

N/A

Custom Runtime

The following programming languages are built into custom runtimes. You can create custom runtimes of the following languages without the need to install third-party interpreters or configure layers:

  • Python 3.7.4 (default Python version)

  • Node.js 10.16.2

  • OpenJDK 1.8.0

  • Ruby 2.7

  • Nginx 1.10.3

  • PHP 7.4.12

    Expand to see a list of built-in extensions of PHP 7.4.12.

    bcmath

    calendar

    Core

    ctype

    curl

    date

    dom

    exif

    FFI

    fileinfo

    filter

    ftp

    gd

    gettext

    hash

    iconv

    imagick

    imap

    intl

    json

    libxml

    mbstring

    mcrypt

    memcached

    mysqli

    mysqlnd

    openSSL

    pcntl

    pcre

    PDO

    pdo_mysql

    pdo_pgsql

    pdo_sqlite

    pgsql

    Phar

    posix

    protobuf

    readline

    redis

    Reflection

    session

    shmop

    SimpleXML

    soap

    sockets

    sodium

    SPL

    sqlite3

    standard

    swoole

    sysvmsg

    sysvsem

    sysvshm

    tokenizer

    xml

    xmlreader

    xmlrpc

    xmlwriter

    xsl

    Zend OPcache

    zip

    zlib

    None

Use a non-built-in programming language

Note

We recommend that you use a public layer to use a non-built-in programming language. For more information, see Configure common layers in the Function Compute console.

If you want to create a custom runtime by using a non-built-in language of the custom runtime, you must compress the interpreter or runtime of the language and your code file into a package and deploy the package in Function Compute so that your functions can run as expected. For example, if the runtime environment is Node.js 16, you must download the interpreter required for Node.js 16, compress the interpreter and your code file into a package, and then deploy the package in Function Compute. Perform the following operations:

  1. Download Node.js of a 64-bit Linux version to the code package directory.

    wget http://mirrors.nju.edu.cn/nodejs/v16.14.2/node-v16.14.2-linux-x64.tar.gz -O node-v16.14.2-linux-x64.tar.gz && tar -zxvf node-v16.14.2-linux-x64.tar.gz && rm -rf node-v16.14.2-linux-x64.tar.gz
  2. Configure the startup command of Node.js in the custom runtime.

    customRuntimeConfig:
      command:
        - /code/node-v16.14.2-linux-x64/bin/node
      args:
        - 'server.js'
    
    # You can also configure environment variables for the function: PATH=/code/node-v16.14.2-linux-x64/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin. 
    # After the configuration is complete, you can directly use Node.js to start the HTTP server. 

Install dependencies

For more information about how to install the dependencies of each programming language in a custom runtime, see the following topics:

You can also use layers of Function Compute to install dependencies. We recommend that you use a public layer or build a dependency layer online. For more information, see the following topics: