geal / serverless-wasm Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
the host functions are imported as raw C like functions, we need a nice API above those, in a crate that can be imported. See https://github.com/CommonWA/cwa-spec for some effort on settling what that interface will look like
the code is currently full of unwrap()
and expect()
calls, let's make it more robust with proper error handling
there should be a way to pass configuration information to the applications, instead of hardcoding it in the assembly. See https://github.com/CommonWA/cwa-spec/blob/master/ns/env.md for more info
Right now, we create an entirely new state for each request. Could we keep the environment (memory, etc) between calls to an app? What happens if we pause it to run another request to the same app? What happens if we get simultaneous calls to the same app?
Could it be better to provide a cache API that wasm apps can query?
In my perfect world, you could launch a swarm of containers to a cloud provider and deploy multiple serverless services to that swarm. The containers and functions would all just auto-scale and optimize. I’d still want to own my container (in at least some sense) so that everything possible could be defined in standard and provider agnostic way.
I’m curious what your vision for the project is? I admit that I might not have enough bandwidth to learn and contribute, but I'm interested.
with the current working version (as of commit f0e2f3e), here is how we can demonstrate the system:
cargo build
(needs rust installed)./target/debug/serverless-wasm ./samples/config.toml
GET /hello
) to specific functions in wasm files (samples/testfunc.wasm
and samples/testbackend.wasm
). The wasm files are already compiled and committed to the repositorycurl http://127.0.0.1:8080/hello
: the server will answer Hello world from wasm!
curl http://127.0.0.1:8080/bonjour
: the server will answer Bonjour tout le monde depuis le monde merveilleux de WASM!
127.0.0.1:8181
like this: nc -l -p 8181
(the port can be changed in the configuration file)
curl http://127.0.0.1:8080/backend
hello
there's currently a small API to open TCP connections to backend servers or databases, but it's pretty limited (returning -1
in case of errors). The host side should return different error codes that we can map to std::io::Error
. Then that API will be more usable (unfortunately, most libraries still assume they will use a std::net::TcpStream
or something from futures)
the current version uses wasmi, which is a very nice interpreter, but we might want to JIT (or more precisely AOT) compile wasm modules to native code, for better performance.
Unsolved questions right now:
while we're looking into async IO (see #4), it should be easier to have a thread pool to which we can give the requests to handle.
What happens to the shared state of the list of modules? Should that be hidden behind a mutex if we want to modify that list dynamically?
There seems to be a spec in the works here:
https://github.com/CommonWA/cwa-spec
there should be a way for the apps to read and write from a FS abstraction. Maybe it would write to the local disk, maybe it would communicate with an external storage, like S3. See CommonWA/cwa-spec#3
It actually depends on to what degree apps running under serverless-wasm
should be sandboxed. One one extereme - there is only one pure function that takes input and returns output and on the other — full control of the host machine (Maybe it should be possible to just forward syscalls from wasm to kernel directly).
But the one approach that bugging me is, what if we can use cloudabi for definition of the host API. This sounds like sorta middle ground between those extremes.
This might be The Most Ambitious Crossover in History...
right now the number of memory pages allocated is hardcoded, it should be possible to request a specific (maximum) amount of memory as part of the configuration for an app.
currently, TCP connections are blocking (ie, they block the whole interpreter). To have a server that handles reasonable load, we might need to have blocking IO on the wasm side, that translates to async IO on the host side.
This is doable if we have a way to pause the interpreter (see wasmi-labs/wasmi#85) and start again once we get an event on the socket.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.