惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
I
InfoQ
V
Visual Studio Blog
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Jina AI
Jina AI
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
The Cloudflare Blog
小众软件
小众软件
雷峰网
雷峰网
V
V2EX
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno
How immutable scripts in Deno allow Windmill.dev (YC S22)...
Ruben Fiszel · 2023-05-18 · via Deno

This is a guest blog written by Ruben Fiszel, Founder & CEO at Windmill.dev.

Windmill.dev is an open-source developer platform where companies can build internal workflows and UIs from scripts. Over 300 companies, including enterprise clients such as PhotoRoom, use Windmill as a core part of their production infrastructure for various operations, such as ETL pipelines, stitching together internal and external APIs, and more.

Since companies rely on Windmill for mission critical workflows composed from scripts, our technology must be performant, secure, and flexible:

  • Minimal cold start time for scripts
  • Securely running untrusted, arbitrary code
  • A simple way to share and compose scripts

Windmill can run Python, Typescript, Bash and Go code. For TypeScript, we chose Deno for its performance, security, and ability to create self-contained scripts.

Scripts as a first class primitive

Scripts are the smallest “unit” for building workflows and UIs, due to their flexibility and control. Windmill workflows are composed of various scripts.

A sample Windmill workflow composed of immutable Deno scripts

Example of a simple single-branch flow to publish on Slack whenever a HackerNews message contains a mention, with sentiment analyzed.

The example above shows that the workflow is not only made of off-the-shelf scripts, but also uses scripts in different languages with all kinds of inputs and resources.

Since scripts are used in all sorts of workflows, their shareability and consistency are important. Also, Windmill is community-driven: scripts are shared on the Hub and all approved scripts are integrated into the product.

With those requirements, the scripts must be reliable, secure and performant. Only Deno offers all of this in one.

Deno makes scripts immutable

Windmill expects each script to expose a main function and declare their dependencies in the same file. The main function’s arguments are parsed to infer the corresponding JSON schema of the payload to trigger such scripts. This model is perfect with Deno.

Deno’s dependency requirements can be stated in the same files where they are used. Furthermore, the import statements can specify the precise version being used, even for npm imports:

import mysql from "npm:mysql2@^2.3.3/promise";
import * as wmill from "https://deno.land/x/windmill@v1.101.1/mod.ts";

When dependency versions are specified, we can guarantee the reproducibility of the execution of the script regardless of environment. On top of that, sharing Deno scripts is as easy as sharing a single file — there’s no need for a separate dependency manifest, e.g. package.json.

Once a script is created or updated, a new version of it is associated with an immutable and perpetual hash, then stored in Postgres with relevant metadata.

With Deno, scripts on Windmill are immutable and a first class primitive — a shareable, composable building block for the entire community.

Running arbitrary code securely with Deno

Windmill runs user generated code in a multi-tenant environment, so it’s imperative that the execution of each script is isolated (for self-hosted installations, for convenience those securities can be disabled). Deno’s opt-in permission model gives us the granularity to control access for each execution.

For Windmill’s scripts in other languages, the sandboxing goes through NSJail, which has a big performance overhead and is complex to use and configure. Deno, due to its secure by default nature, has an edge in performance for multi-tenant environments.

Minimal cold starts with Deno

We’ve been able to achieve 15ms cold start times with Deno, thanks to its integration with V8 and immutable caching of dependencies

The dependencies that are cached are also propagated across workers of a cluster with a sync system backed by S3, so any Deno script that references a cached dependency won’t need to download it and reap performance benefits.

The cold start of executing a Deno script is around 15ms, which means that most lightweight scripts run 30ms end-to-end.

What’s next?

We’ve been happy using Deno in production at Windmill — it’s simplified development, added a layer of security, and ensured optimal performance for our enterprise clients.

In the future, we aim to match serverless / AWS lambda performance by integrating more deeply with Deno and running it in process.

Don’t miss an update — follow us on Twitter.