logo

Safe, Dynamic Middleware with Dapr and WebAssembly

2023-04-20

Authors:   Mauricio Salatino, Adrian Cole


Summary

The presentation discusses the use of webassembly in Dapper, a distributed application platform, and how it can be used to change the logical inside the deployed cells. The presentation also introduces the HTTP middleware component and the Wasm runtime that is embedded into the Dapper sidecar to run the filter.
  • Webassembly can be used to run third-party code inside the same process without launching another process
  • Dapper started exploring the use of webassembly in 2019
  • The zero dependency webassembly runtime for Go was used to embed webassembly virtual machine into a Go process
  • The HTTP middleware component was introduced to allow users to change requests or response
  • The Wasm runtime is embedded into the Dapper sidecar to run the filter
The presenter talks about how the webassembly community wasn't strong in Go yet, and how they had to rely on the zero dependency webassembly runtime for Go to embed the webassembly virtual machine into a Go process. They also discuss how they designed the SDK to be faster and more developer-friendly than the proxy wasm used by Envoy.

Abstract

Join us for a practical talk on how the Dapr event-driven runtime implements dynamic extensions with WebAssembly. We'll cover how things work in general as well rationale and a peek into implementation. When you leave, you'll have a good idea of how WebAssembly lets you extend cloud native architecture without RPC. Dapr allows custom processing pipelines to be defined by chaining a series of middleware components. A request goes through all defined middleware components before it’s routed to user code, and backwards through the same components before a response is returned to the client. This talk shows how custom HTTP middleware can used without changing the Dapr binary, using WebAssembly technology. Dapr loads these dynamically and without requiring any system dependencies or RPC services. Specifically, we'll review the http-wasm application binary interface (ABI) which SDKs implements, and how this relates to other ABI like proxy-wasm or waPC. Well cover how the middleware works, including the wazero runtime which Dapr embeds to run wasm without system dependencies. Finally, we'll chat about how this fits into Dapr's long-term strategy in extensibility.

Materials: