Browse Chapters
WebAssembly and Serverless Apps
Earlier in the Complete Developer’s Guide to Serverless Apps, we talked about how WebAssembly (sometimes abbreviated to Wasm) is a key enabling technology for today’s new class of serverless apps. In this section, we will cover the basics of Wasm and serverless apps and see why it is such a promising technology.
Defining Wasm
Wasm was created in 2015, and standardized by the W3C (the standards body responsible for HTML and CSS) in 2019. Wasm was originally built specifically for the web browser. Its original promise was to make it possible to run a wide variety of programming languages (C, C++, Rust, Python, etc.) inside of the web browser alongside JavaScript.
The standard defined a binary format that programming language compilers could target. So the Rust compiler, in addition to compiling to Linux, Mac, and Windows formats, could also compile straight to Wasm.
Wasm is operating system and platform agnostic. The same Wasm binary can run on any of these platforms without alteration. Likewise, Wasm does not care about processor architecture and can run on Intel, Arm, and other processors. These design factors were simply necessary for the browser use case. It simply would not do for a browser on Windows to be unable to execute the same browser code as a browser on Mac.
When we visit web pages, we have a very low tolerance for latency. We don’t like staring at a white screen and waiting for a page to load. The authors of Wasm considered this and made sure to define a format that could load and execute very quickly.
Wasm has one additional feature that is worth emphasizing: a strong security layer. When a Wasm program is executed inside of a browser, it is strongly sequestered not just from the host computer’s operating system, but even from the JavaScript also running in the browser. Why? Because the creators of Wasm wanted to make sure that Wasm would not become an attack vector for hackers.
Moving Wasm from the Browser to the Cloud
We just listed three important features of Wasm:
- Independent of operating system and processor.
- Fast to load and execute.
- Securely isolated code.
Those three features are good for the browser. They are absolutely necessary for the cloud. So when we at Fermyon were looking to build a cloud computing runtime that was cross-platform and cross-architecture, loaded and ran fast, and had great security, Wasm jumped out as an ideal technology. We took a technology originally built for the browser and pulled it into the cloud. And it is an excellent fit.
Serverless Apps and Wasm
Earlier, we provided three definitions of serverless. The third definition described writing apps that handled individual requests without having to write software servers. AWS Lambda is one example of this technique. Fermyon Cloud is another.
A core difference between Fermyon Cloud and AWS Lambda is that Fermyon Cloud uses Wasm as the runtime. That is why Fermyon Cloud executes serverless apps so much faster and so much more cost-effectively than Lambda. We will go into the details later in this guide. But for the moment, the important detail is that Wasm’s strengths make it the ideal candidate as an underlying technology for serverless apps.
In a few chapters, we’ll delve into the details of writing and executing serverless apps using Wasm. But we have a little more work to do first. In the next section, we will look at serverless apps and serverless functions, and see how those two concepts relate.
Browse Chapters