WebAssembly Compute Jobs
Run code compiled to WebAssembly on GridGain 9 cluster nodes, including runtime configuration, instance caching, and building modules in Rust, Go, WebAssembly text format, and Python.
You can run your code compiled to WebAssembly with GridGain 9 Compute API. By default, WASM code will be compiled into JVM bytecode for faster execution. You can configure this behavior in the compute configuration.
Use JobExecutorType.WASM_EMBEDDED to load WebAssembly binaries as deployment units and execute the code on cluster nodes.
Before submitting your compute job, ensure that the required code is deployed to the nodes where it will execute.
GridGain 9 uses Chicory 1.5.1 WebAssembly runtime.
See supported Wasm features here: https://webassembly.org/features/
Runtime and configuration
By default, WebAssembly code is compiled to JVM bytecode at runtime for faster execution (Chicory runtime).
You can control this behavior with the compute.wasm.enableCompiler setting in the compute configuration.
Instance Caching
To reduce the startup overhead of module loading and initialization, especially noticeable with some runtimes (for example, Go), GridGain 9 caches WebAssembly instances.
Instances are cached per deployment unit and file name, avoiding repeated loading and initialization.
Cached instances are automatically cleared when the corresponding deployment unit is undeployed.
Configuration Example
Add the following snippet to your gridgain-config.conf to define module memory, cache size and TTL parameters.
WebAssembly Modes
GridGain 9 supports two execution modes for WebAssembly modules:
Reactor mode - Calls specific exported functions from the module.
Command mode - Runs the module as a standalone program that reads input from stdin and writes output to stdout.
The sections below show how you can use these modes, and the recommended platforms for them.
WebAssembly Reactor Mode
The following sections explain how to build and deploy modules in Rust, Go, and WebAssembly Text Format (Wat).
Rust
Make sure Rust and Cargo are installed.
Install
wasm-pack:
Create a new Rust library project:
Replace the contents of
Cargo.tomlwith:
Replace the contents of
src/lib.rswith:
Build the project with
wasm-pack build. This will create apkgdirectory with the compiled Wasm module and JavaScript bindings. We only need one.wasmfile from this directory:pkg/hello_wasm_bg.wasm.Deploy the
.wasmfile as part of a Deployment Unit to your cluster.Run your Rust job using Compute API:
For more details, refer to Wasm documentation for Rust:
Go
Make sure Go is installed.
Create a new directory for your project:
Initialize a new Go module:
Create a new file
hello.gowith the following contents:
Build the project:
Deploy the
.wasmfile as part of a Deployment Unit to your cluster.Run your Go job using Compute API:
For more details, refer to Wasm documentation for Go:
https://go.dev/wiki/WebAssembly
WebAssembly Text Format
Go to https://webassembly.github.io/wabt/demo/wat2wasm/ and paste the following code into the left pane:
Click the Download button.
Deploy the downloaded
.wasmfile as part of a Deployment Unit to the cluster.Invoke the functions with Compute API:
For more details, refer to Wasm documentation for WebAssembly:
https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Understanding_the_text_format
WebAssembly Command Mode
Some languages and toolchains do not support exported functions. Python with py2wasm is one such example.
Command mode provides a simpler interaction pattern via stdin/stdout, but is less efficient, because the module has to be started again on every job execution.
The following section describes how to build and deploy modules with py2wasm (experimental, requires Python 3.11).
Python
Install
py2wasm:
Create a Python script, for example:
Build the WebAssembly module:
Deploy the created
hello.wasmfile as part of a Deployment Unit to the cluster.Run your Python job using Compute API with command mode:
The commandBuilder() method automatically configures the job to use command mode execution. The input string is passed to the program's stdin, and the output is captured from stdout.
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

