Deploying serverless Rust functions with Zeet and WebAssembly

Introduction

While the power of WebAssembly inside the browser goes without saying, there’s a huge potential for taking WASM to places outside the realm where it was originally intended. The argument for WASM on the backend is growing in support for a variety of reasons that we’re going to look at now.

In this blog post, we’re going to introduce you to what is driving support for leveraging WebAssembly outside the browser in use cases such as serverless computing, and afterwards we will take a look at how we can use Zeet to deploy our own WASM-based Rust function.

What is WASM?

Currently, the development of most serverless applications is dominated by high-level languages such as Javascript and Python. The problem with this paradigm is that in terms of performance, these high-level languages are well known for being up to 60,000 times slower than low-level and assembly-like languages such as C or C++.

The goal of WASM is to combine the performance and security of an assembly-like language with the convenience of high-level languages. It acts as an intermediary compiler target for your source code by providing a virtual machine (VM) that runs the application’s code. Solomon Hykes, the co-founder of Docker, had this to say about it:

It’s as Solomon said, WASI provides a standard and modular system interface for running WebAssembly outside of the web.

Deploying your functions with Zeet

Prerequisites

  1. A Zeet Account
  2. A Rust application
  3. A Github Account

Before you do anything, we’re going to need to log into Zeet or create a profile if you haven’t already done so. Once you’re setup, it’s time to create a new project. The repository we’re going to use for this project is a very simple example by Colin Eberhardt that you can find here -- a simple Hello World run in Serverless. Now we’re going to want to select GitHub as the source of our application, as well as the repo.

Once you’ve done that, all you need to do is check your configuration settings and deploy!


Something interesting to note is the difference in price when deploying this simple application to AWS via Serverless compared to choosing the containerized option that Zeet leverages Kubernetes for. As seen below, if we were to choose the Lambda option with this application, the estimated cloud cost comes out to “free”.


On the other hand, if we had chosen the Dockerized option, it comes out quite a bit more expensive at $37.50/mo.


It goes without saying that if you have the option to choose a technology that performs better for less cost, you’re going to want to go with that one.

Conclusion

It seems like only recently people were trying to wrap their minds around the concept of containers in infrastructure. Now, we see a completely new paradigm popping up that was meant originally for the browser, but showing promise for many different use cases from edge computing to serverless. It’s definitely an exciting time to be in this industry.

Johnny Dallas

Johnny Dallas