Capsule: the nano (WASM) functions runner


97 points | by rcarmo 59 days ago


  • bsaul 59 days ago
    Side question : is nats a credible alternative to kafka nowadays ? I’ve read it could do the same things in theory, but i haven’t heard of real world experience feedbacks with this tech.
    • paulgb 59 days ago
      I haven't used Kafka in production, but we use NATS in Spawner[1] and I find it quite pleasant to work with. It gives you some basic but powerful messaging constructs (request/reply, queue groups, temporal decoupling via Jetstream) and then gets out of your way.


    • asim 59 days ago
      NATS is very powerful. The author has like 25 years of experience building messaging systems and NATS has been around for a long time. The streaming component is slightly newer but I'd say it does the same job as Kafka but much lighter footprint with zero deps.
    • superzamp 59 days ago
      Side answer to your side question: not sure for NATS, but Redpanda is trying to be a lightweight drop-in alternative
    • deforciant 59 days ago
      It's great actually, you can run it with pretty much no maintenance overhead. I have been using it in prod in multiple companies for years now
  • k33g 58 days ago
    Hello, I'm the "father" of Capsule. It's a Golang app, and I use the Wazero project as the wasm runtime ( Capsule loads and executes the WASM modules like a CLI or serves the module through an HTTP server or as a NATS or MQTT subscriber. Right now, you can only build the WASM modules with TinyGo, but my next plan is to make my code more agnostic.

    I started this project this summer to improve my GoLang knowledge and test some ideas on WASM and WASI. Everybody is welcome for any advice, PR, etc.

  • norman784 59 days ago
    I was thinking on build my local serverless server, so I can deploy my services easily (almost as easy as docker, but with less overhead I think), there are few downsides I think and it's that docker let more variety of software run, while a serverless host need specifically or in most cases Wasm.

    Said that I have no idea how to start, will this be a good foundation to build an easy to deploy local server? (think of aws lambdas, vercel, cloudflare workers,, etc).

    • qbasic_forever 58 days ago
      Do you want to use a FaaS or just toy with making your own? If you just want to use something check out OpenFaaS, it's very easy to get started and is well documented:

      If you want to build your own FaaS, I'd still explore OpenFaaS as its creator has documented a lot of its creation and you will soon discover the critical things you'll need to figure out for building your own similar service (i.e. stuff like sandboxed execution environment, API gateway, scaling up and down functions, etc.).

      • norman784 58 days ago
        Thanks, I will check OpenFaaS out.
  • inhumantsar 58 days ago
    Potentially stupid question: I can see the benefit of running Go-compiled-to-WASM client side but I don't really get why I might want to run WASM server-side.

    What would be the benefit of server-side WASM over running a Go binary directly? To run untrusted binaries alone or are there other benefits?

    • debarshri 58 days ago
      WASM is often pitched as a potential alternative to docker and other OCI compatible alternatives. It does not have to be a go-compiled-to-wasm, it could be python compiled to WASM, or rust for that matter. Either ways, you could use any function runners like these, Wasmer [1] or any webassembly runtime to run them on a host.


    • 0x457 58 days ago
      WASM on server-side main benefits are: easy sandboxing, being polyglot, hot-reload.

      This one seems not quite polyglot, but it's easy to change.

      I think WASM, once WIT (or something similar) gets into spec, will be a wonderful way to make plugins for your service.

  • elesbao 59 days ago
    been playing with firecrackervm and this seems a perfect runtime for my small images with wasm.
  • moralestapia 58 days ago
    In case someone knows, is there a way to use this lib but compiling from JS instead of Go?
  • praveen9920 59 days ago
    The documentation is one of the cleanest I’ve seen in recent days. Kudos
  • rebolyte 58 days ago
    Interested in this! thanks for the clear examples in the readme