Spin Brings WebAssembly To The Cloud |
Written by Nikos Vaggalis | |||
Tuesday, 07 February 2023 | |||
Spin is a new open source framework for building and running cloud microservices with WebAssembly which run on the Fermyon Cloud. Fermyon has also released an SDK for .NET. First, WebAssembly was touted as a runtime that would be embedded into every major web browser in order to write code in any language that could be compiled to its bytecode format. Because of that, the popular browsers would be able to execute not just JavaScript but also compiled binaries, hence the second property that was attached to it;the Javascript killer. . As things progressed, both of those assumptions were debunked. WebAssembly has broken loose of the browser's constraints and can be used for running Microservices or serveless functions or even run Wasm binaries on the command line so that even cross-platform CLI applications can be developed. So rather than kill JavaScript it might even interoperate with it. But back to WebAssembly for the Cloud. Fermyon has made Spin: a framework for web apps, microservices, and other server-like applications. Spin provides the interfaces for writing WebAssembly modules that can do things like answer HTTP requests. One unique thing about Spin is that it is a multi-language framework. Rust and Go both have robust support in Spin, but you can also write Python, Ruby, AssemblyScript, Grain, C/C++, and other languages. With Spin you reduce the overhead of microservices by factoring out the web server (replaced by a WAGI server) and writing out HTTP handlers in whatever language we want (Rust, C, JavaScript, Python, etc), which are then compiled to WebAssembly. The host runtime will provide the features necessary, such as a filesystem (a highly sandboxed one), outbound HTTP, key/value storage, etc. Therefore we can focus our microservices on handling the business logic, leaving the underlying platform to manage all of the HTTP, SSL Certificates, and so on. With Spin you also satisfy the necessary requirements that need to be in place for Cloud computing applications:
Here’s what a Spin “Hello World” looks like written in Rust:
Writing a Spin module is not much different in Go:
Spin v0. 7. 0 version of the framework released last month comes with:
Fermyon has also released an SDK for . NET which can be used to:
So there you have it, WebAssembly as a better, lighter alternative to VM's, containers and Kubernetes.
More InformationA simple URL shortener built with Spin Related ArticlesBlazor WebAssembly Crash Course WebAssembly Explorer - A Learning Tool WebAssembly Takes A Big Step Towards Being Real WebAssembly Has Mozilla, Microsoft,Apple and Google Backing It
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Thursday, 16 February 2023 ) |