Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WebAssembly auf dem Server und in der Cloud mit Fermyon Spin

WebAssembly auf dem Server und in der Cloud mit Fermyon Spin

WebAssembly (Wasm) ändert alles! Dabei ist Wasm im Browser nur die Spitze des Eisbergs. Die Auswirkungen von Wasm auf der Serverseite (oder in der Cloud) werden sich bald wesentlich stärker darauf auswirken, wie wir Anwendungen implementieren, verteilen und ausführen. In diesem Talk führt Sie Cloud-Native-Enthusiast Thorsten Hans durch die zugrundeliegenden Ideen, erklärt essenzielle Konzepte wie WASI und WAGI und veranschaulicht die Bausteine, mit denen Sie Ihre WebAssembly-Reise starten können. Gemeinsam tauchen wir in Spin ein, ein SDK, eine Laufzeit und eine Entwickler-Toolchain, welche von Fermyon erstellt wurde, und lernen Microservices mit Wasm zu erstellen.

Thorsten Hans

May 09, 2023
Tweet

More Decks by Thorsten Hans

Other Decks in Technology

Transcript

  1. WebAssembly auf dem
    Server und in der Cloud
    Thorsten Hans
    @ThorstenHans
    Cloud-Native Consultant
    mit Fermyon Spin

    View full-size slide

  2. Consultant @ Thinktecture
    #Azure #Containers
    #CloudNative #Wasm
    [email protected]
    thinktecture.com
    thorsten-hans.com
    @ThorstenHans
    Microsoft MVP | Docker Captain
    Thorsten Hans

    View full-size slide

  3. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  4. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  5. WebAssembly (Wasm)
    • It’s virutal machine that processes stack-based instructions
    • Instruction are in binary format
    • High performance runtime that devs can target using “almost” every language*
    * https://www.fermyon.com/wasm-languages/webassembly-language-support
    Introduction

    View full-size slide

  6. WebAssembly (Wasm)
    • Fast 🏃
    • Near native execution performance, leveraging available hardware capabilities
    • Safe 💪
    • Wasm is a sandboxed, memory-safe execution environment
    • Portable 🧊
    • All major browsers support Wasm & multiple ”server” Wasm runtimes available
    Introduction

    View full-size slide

  7. WebAssembly System Interface (WASI)
    • Platform Integration 🧬
    • WASI is a wrapper for underlying platform (OS) capabilities
    • Think of things like File:: open()
    • Portable 🧊
    • WASI could become the default compiling target for EVERYONE!
    • Secure 👮
    • Permissions can be defined per app (module)
    Introduction

    View full-size slide

  8. Portability
    Introduction
    https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

    View full-size slide

  9. Security
    Introduction
    https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

    View full-size slide

  10. Security
    Introduction
    https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

    View full-size slide

  11. Security
    Introduction
    https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

    View full-size slide

  12. Security
    Introduction
    https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

    View full-size slide

  13. WebAssembly Gateway Interface (WAGI)
    • Use WebAssembly modules as HTTP handlers
    • Think of a hyper-focused microservices runtime
    • Comman Gateway Interface (CGI) implementation
    • HTTP headers become environment variables
    • HTTP payloads are piped to stdin
    • HTTP responses must be written to stdout
    Introduction

    View full-size slide

  14. WebAssembly will change the way we architecture
    distributed systems in the future

    View full-size slide

  15. • Cloud-vendor interest:
    • They can put more apps on a compute resource as today
    • Wasm and WASI give them a strict security and isolation model
    • Wasm workloads are way smaller than everything else
    • They can scale to zero due to super-fast bootstrapping
    Intro
    Why will Wasm have such a big impact?

    View full-size slide

  16. • Developer interest:
    • We can use any language that compiles to wasm32_wasi
    • We can ship just the app (not the webserver, not the OS)
    • We can reduce cloud spendings
    • Workloads will be cheaper because they consume way less
    resources and execute faster
    Intro
    Why will Wasm have such a big impact?

    View full-size slide

  17. Wasm on the server relates to containers in the same
    way containers related to
    virtual machines 10+ years ago

    View full-size slide

  18. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  19. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  20. Fermyon Spin is:
    • A serverless runtime build using Wasm, WASI, and the
    WebAssembly Component Model (leveraging wasmtime internally)
    • A collection of SDKs for many popular languages
    • A super focussed developer tooling
    Intro
    Let’s get everybody on track!
    🦀

    View full-size slide

  21. Let’s meet Fermyon Spin
    Walk through the demo application
    Demo

    View full-size slide

  22. • Spin provides triggers that the runtime uses to invoke our code
    • The runtime instantiates our Wasm Module and invokes our code
    • Currently, Spin provides the following triggers
    • HTTP
    • Publish / Subscribe
    Let’s meet Fermyon Spin
    Triggers & Outputs

    View full-size slide

  23. Outputs allow our code to interact with the surrounding world
    • Databases (SQLite, MySQL & PostgreSQL)
    • Key-Value Storage (SQLite, Redis)
    • Publish / Subscribe (Redis Channels)
    • Outbound HTTP
    Let’s meet Fermyon Spin
    Triggers & Outputs

    View full-size slide

  24. • Considering Fermyon Spin, try to spot reactive parts of your
    application
    • Check if necessary libraries are available for the wasm32_wasi platform
    • Deploy Fermyon Platform to your infrastructure of trust
    Intro
    How to adopt Wasm on the server / in the cloud

    View full-size slide

  25. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  26. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  27. Regardless of whether we must invoke backend APIs or 3rd party
    endpoints, Outbound HTTP is an easy to grasp, yet important capability
    provided by the Spin SDK.
    Patterns & Practices
    Outbound HTTP

    View full-size slide

  28. Outbound HTTP leveraging the Spin SDK
    Demo

    View full-size slide

  29. Configurability is mission-critical when building software that is
    executed in different environments.
    Spin apps are no exception here. We must use proper mechanisms to
    deal with sensitive and non-sensitive configuration data.
    Patterns & Practices
    Configuration Management

    View full-size slide

  30. • The Spin Manifest spin.toml is the center of gravity.
    All configuration aspects are defined here.
    • We use variables to specify non-sensitive configuration data
    • For sensitive configuration data, we can use HashiCorp Vault
    • We link HashiCorp Vault to our app using a runtime-config file
    Patterns & Practices
    Configuration Management

    View full-size slide

  31. Configuration data for Spin apps
    Demo

    View full-size slide

  32. • Publish is achieved using the Spin SDK
    • Constructing messages is up to us, which means we can modernize
    (read: replace containers) with ease, using cloudevents or by
    mimicking existing messages
    • When subscribing to messages, we must implement filters on our own
    Patterns & Practices
    Publish / Subscribe

    View full-size slide

  33. Publish / Subscribe in distributed apps with Spin
    Demo

    View full-size slide

  34. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  35. • Intro
    • Let’s meet Fermyon Spin
    • Patterns & Practices
    • Conclusion
    Agenda

    View full-size slide

  36. • With Spin, Fermyon demonstrates how WebAssembly will change the way we build
    software for the next wave of cloud-computing
    • We’re able to combine best from both worlds, Containers and WebAssembly to build
    distributed architectures for the upcoming years
    • Available Spin SDKs and plain WAGI support makes it super easy to get started
    (using any language that compiles to Wasm)
    Conclusion

    View full-size slide

  37. • Hyperscalers want Wasm to drive hardware utilization, lift smaller application packages, get
    proper isolation and security in place and scale horizontally to and from 0 without facing the
    dilemma of cold-start times (Looking at you, Azure Functions *scnr*).
    • Application developers on the otherside had to tacklequite some pitfalls to adopt Wasm
    (SDKs., dev tooling, etc)
    • From my point of view, Fermyon is able to close the gap and drive Wasm adoption
    on the server and in the cloud to whole new level
    Conclusion

    View full-size slide

  38. Thanks for your attention
    @ThorstenHans @Thinktecture

    View full-size slide