GithubHelp home page GithubHelp logo

justjavac / deno_serverless_aliyun_minimal Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 0.0 25 KB

为阿里云 serverless 平台添加 Deno Runtime,精简版,从源码编译 deno_core with V8 snapshot

Makefile 3.69% Rust 79.83% JavaScript 16.48%

deno_serverless_aliyun_minimal's Introduction

阿里云函数计算 Deno FC Runtime

Deno + Serverless = Awesome

背景

两年前(2020年)我曾经写过一个项目,给阿里云的 Severless 开发了可运行 Deno 的 Custom Runtime: deno_serverless_aliyun

今天我重新从源码编译了 deno_core,并且把 src/fc_runtime.js 编译为了 V8 Snapshot 进一步缩短冷启动时间。

注意⚠️:本项目不是一个完整的 Deno Custom Runtime⚠️

前置工具

  • Serverless Devs
  • Docker(如果你使用 linux 系统,可以不安装 Docker)

配置

安装 Serverless Devs 成功后运行 s config 配置 Account ID、Access Key ID、Secret Access Key、Default Region Name。

克隆(或下载)本仓库:

git clone [email protected]:justjavac/deno_serverless_aliyun_minimal.git

部署

cd deno_serverless_aliyun_minimal
make deploy

自定义部署:

  1. 使用 Rust 编译 bootstrap。

    cd bootstrap
    cargo build --release

    非 linux 系统使用 Docker 构建:

    make build
  2. 构建 Deno Serverless 运行环境:

    s build
  3. 部署

    s deploy

测试

部署完成后我们可以测试刚才的函数。

s invoke --event "Hello World"

控制台输出:

...
FC Invoke Result:
Hello World

第一次运行时函数需要冷启,会稍微有点慢。

对比之前的 Deno + JS:

Duration: 9.27 ms, Billed Duration: 12 ms, Memory Size: 512 MB, Max Memory Used: 41.50 MB
Duration: 1.66 ms, Billed Duration: 2 ms, Memory Size: 512 MB, Max Memory Used: 41.62 MB
Duration: 1.41 ms, Billed Duration: 2 ms, Memory Size: 512 MB, Max Memory Used: 41.87 MB
Duration: 1.50 ms, Billed Duration: 2 ms, Memory Size: 512 MB, Max Memory Used: 42.25 MB
Duration: 1.41 ms, Billed Duration: 2 ms, Memory Size: 512 MB, Max Memory Used: 42.50 MB

Deno_core + V8 Snapshot 的启动时间:

Duration: 1.21 ms, Billed Duration: 2 ms, Memory Size: 512 MB, Max Memory Used: 18.02 MB
Duration: 0.78 ms, Billed Duration: 1 ms, Memory Size: 512 MB, Max Memory Used: 22.96 MB
Duration: 0.67 ms, Billed Duration: 1 ms, Memory Size: 512 MB, Max Memory Used: 23.08 MB
Duration: 0.73 ms, Billed Duration: 1 ms, Memory Size: 512 MB, Max Memory Used: 22.64 MB
Duration: 0.67 ms, Billed Duration: 1 ms, Memory Size: 512 MB, Max Memory Used: 23.12 MB

注意⚠️:本项目不是一个完整的 Deno Custom Runtime⚠️

deno_serverless_aliyun_minimal's People

Contributors

justjavac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.