WebAssembly in the Cloud

Every big cloud provider today has some form of support for serverless computing, or “cloud functions.” They each have their own name for it, and each one of the providers tries to add value in their own unique way to convince customers that their function hosting is better than everyone else’s. Amazon AWS has Lambda,[50] Google Cloud Platform has Google Cloud Functions,[51] Microsoft has Azure Functions,[52] and Alibaba Cloud has Function Compute.[53]

To the best of my knowledge, none of these serverless platforms has any kind of native support for WebAssembly—yet. I am hopeful that by the end of 2019, at least one of the major providers will allow for some kind of native integration of WebAssembly modules into cloud functions. Just the binary portability alone makes this an appealing offering. Some providers may be waiting for the host interface to get a little more robust (e.g., to allow native string passing so there wouldn’t have to be explicit allocation calls in the host contract).

Today, Amazon Lambda supports a Rust runtime for functions. This means you could take the Rust WebAssembly host code examples from this book and write a host that consumes JSON events, converts them into something suitable for the hosted module, and invokes a function. Is this really worth the overhead, though? Do we actually gain any benefit from creating another nested layer within a cloud function?

In some cases it might be useful. Given the limited abilities of a WebAssembly module, they become notably easier to test. For example, a JavaScript function that makes external HTTP requests would require complicated mocks, injection, or standing up a fake server to test properly. But if the WebAssembly module just invoked a make_http_request function, then a test harness for that module could easily fake it. Whether this additional degree of indirection is worth it depends on you, your development team, and of course the problem you’re trying to solve. This scenario does gain a bit more traction when you plan on running the same logic both inside and outside of the serverless platform.

As the WebAssembly specification grows and the community of developers creating Wasm-based solutions also grows, I expect a lot of people to notice the potential of combining WebAssembly’s performance, security, and portability with the flexibility and cost-effectiveness of cloud functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.121.153