WebAssembly (Wasm), originally invented and developed by Mozilla, Google, Microsoft, Apple, and others at W3C; is a high-performance execution engine for in-browser web applications. As it gains popularity on the client-side, Wasm is also becoming a serious contender as a server-side technology.
Check out how to run high-performance Rust functions in Node.js web apps. In this setup, the Rust function is compiled to portable WebAssembly bytecode and runs safely in a WebAssembly VM.
When compared with containers like Docker, Wasm provides a higher level of abstraction, and hence higher productivity, for developers. Wasm can deploy code and applications instantly, instead of launching operating systems.
Wasm consumes much less memory and resources than typical containers. In particular, its security model allows modular access to the underlying hardware and Operating System (OS), on a per-function call basis, ensuring safety while retaining native performance.
If WASM+WASI existed in 2008, we wouldn’t have needed to created Docker. That’s how important it is. WebAssembly on the server is the future of computing. — Solomon Hykes, Co-founder of Docker
Furthermore, the server-side Wasm benefits from significant innovations coming from the blockchain community.
Blockchain leads the way
Server-side Wasm is currently in an early stage. A significant amount of work (optimizations, developer tools, and integration libraries) has to be done before Wasm can see meaningful adoption in enterprise settings. However, developers are already using it for microservices in an emerging field of enterprise computing; decentralized blockchain applications.
Blockchain smart contracts are immutable and automatically executed code. Applications, known as decentralized applications (or dapps), can interact with smart contracts via web interfaces i.e. Remote Procedure Call (RPC) service endpoints. That makes smart contracts natural microservices.
Large public blockchain networks, such as Ethereum, EOS, and Polkadot, have all committed to adopting Wasm as their next-generation execution engines. As a result, the public blockchain, with its decentralized and serverless infrastructure is the best platform to write and deploy Wasm services today.
Moreover, the server-side Wasm can directly leverage billions of dollars worth of R&D investments poured into the blockchain space in recent years. Many of those blockchain R&D innovations are highly relevant to enterprise use cases; even those inside centralized data centers. Some of those use cases include:
- Metered and billable shared resources usage accurate to opcodes
- Trustless consensus for computing results
- Digital currency infrastructure support
- Formal verification of applications
- Zero-knowledge computing
- Improving deterministic behavior of applications
Show me the code
The Second State VM (SSVM) is a WebAssembly runtime that is specifically optimized for server-side applications.
- It provides a comprehensive set of tools for server-side and serverless applications in Node.js. Check out the Getting started guide.
- It fully supports the WASI specification for accessing operating system resources.
- It features Ahead-of-Time (AOT) compiler optimization, which drastically improves server-side application performance. It is the fastest WebAssembly on the market today.
- It supports stateful application through an attached object storage database accessible from inside the VM.
- It supports direct access to AI hardware from inside the VM.
To see some code examples, check out the following tutorials.
- Image recognition using Tensorflow.
- Machine learning and visualization as a service.
- Privacy computing as a service.
- Getting started with decentralized blockchain apps (DApps).
On the blockchain, the SSVM is at the forefront of providing Ethereum-flavored WebAssembly (Ewasm) for the next-gen Ethereum-compatible blockchain systems. The SSVM, for blockchain, natively supports 256-bit integer operations. It handles non-deterministic opcodes and gas computation inside the VM, resulting in much-improved performance compared with other leading Ewasm implementations.
The road ahead
The road ahead for Wasm on the server-side is very promising. We look forward to sharing more of our cutting-edge developments as we blaze a trail; evolving toward the next-gen cloud architecture!
If you would like to learn more about anything mentioned in this article, please contact us at SecondState.io