New Feature: dynamic load wasm file #191
Labels
help wanted
Extra attention is needed
kind/enhancement
New feature or request
wasm
WebAssembly technology
1. What would you like to be added
Currently Layotto only supports static loading
*.wasm
files, that means which*.wasm
files to be loaded must be written in the configuration file at the beginning. Take thedemo/wasm/config.json
configuration file as an example , The following configuration means that Layotto needs to loadwasm_1_1.wasm
,wasm_1_2.wasm
,wasm_2.wasm
.2. Why is this needed
This is the problem that Layotto faces in the FaaS scenario. When Layotto is started as the base for Function, it doesn't know which
*.wasm
files to load, and it needs to wait for schedule center to call them to load*.wasm
file.3. Design draft
A. interface definition
Layotto needs to provide an HTTP interface. Considering the unified management of the Listener, we do not recommend calling the native listener API in the code, but handing it over to MOSN management. This can also reduce the amount of development, specific configuration and Code development can refer to the actuator module implemented before.
actuator user doc
actuator HTTP configuration
actuator HTTP biz logic
The expected method of calling the loading interface is as follows:
The expected way to call the uninstall interface is as follows:
Expansion point: Here you can also consider not uninstalling all of them, but just reducing the number of instances, similar to the expansion and contraction of Function.
B、Loading file
Here you can ignore the scenario of letting Layotto download the wasm file in the server, just assume that the target file has been saved in a certain path of the target node, we just need let Layotto load and run this file according to the configuration.
中文
一、需要实现什么功能
目前Layotto只支持静态加载
*.wasm
文件,也就是说要加载哪些*.wasm
文件,必须一开始就写在配置文件中,以demo/wasm/config.json
配置文件为例,如下配置表示Layotto需要加载wasm_1_1.wasm
,wasm_1_2.wasm
,wasm_2.wasm
三个*.wasm
文件,并指明了它们对应的配置。现在,我们需要让Layotto能支持通过接口调用的方式动态加载
*.wasm
文件,并按照对应的配置信息来运行。二、做这个功能的价值
这是Layotto在FaaS场景中面临的问题,当Layotto作为FaaS运行的基座启动以后,它并不能预先知道要加载哪些
*.wasm
文件,需要依赖调度中心根据待发布的Function所需要的资源计算好目标节点以后,再调用节点上面运行的Layotto接口来让它动态加载并运行目标函数。三、方案概述
A、接口定义
Layotto需要对外提供HTTP接口,考虑到对Listener的统一管理,我们不推荐在代码中调用原生的监听端口函数,而是要交给MOSN管理,这种方式同样也可以减少开发量,具体的配置及代码开发可以参考之前实现的actuator模块。
actuator使用文档
actuator HTTP服务的配置方式
actuator HTTP服务的处理逻辑
预期的加载接口调用方式如下:
预期的卸载接口调用方式如下:
扩展点:这里也可以考虑不全部卸载掉,而只是减少实例数,类似于Function的扩缩容。
B、文件加载
这里可以先不考虑让Layotto去远端下载wasm文件的场景,只需假定目标文件已经提前保存在目标节点的某个路径下面,按照自定义配置加载运行即可。
The text was updated successfully, but these errors were encountered: