6 ms·
Maybe a stupid question, but: what is Wasmtime for? What kind of use-cases/applications does it enable and why is this good?
by lhnz 4y ago
Maybe a stupid question, but: what is Wasmtime for? What kind of use-cases/applications does it enable and why is this good?
- dljsjr 4y agoThe Bytecode Alliance is a nonprofit group with members from all over the industry working to provide what is ostensibly a reference implementation of a WebAssembly runtime w/ full WASI support. Wasmtime is their implementation. They are far from the only implementation, though. You can find links to other runtimes in other comments here already.
- oxff 4y agohttps://blog.cloudflare.com/announcing-wasi-on-workers/ https://blog.cloudflare.com/announcing-wasi-on-workers/ will probably open it up a bit for you with a concrete example
- baq 4y agoThanks for that. > Back to the future > For those of you who have been around for the better part of the past couple of decades, you may notice this looks very similar to RFC3875, better known as CGI (The Common Gateway Interface). While our example here certainly does not conform to the specification, you can imagine how this can be extended to turn the stdin of a basic 'command line' application into a full-blown http handler. they should've started with that ;)
- btown 4y agoI would add that it can be useful to have isolated runtimes even if you're not a PaaS. Say you need to parse an obscure file format that can be uploaded from untrusted users (and nowadays, that's all users). You've got some ancient C or C++ source code for the parser, but it hasn't been vetted for security or denial-of-service issues. Compile it to WASM, run it in an isolated runtime, and you can be confident that it won't be able to escape its sandbox while also minimizing startup times and using significantly fewer resources than needing a container for each invocation.
- jon-wood 4y agoPersonally I’d want to be very cautious about this. It’s probably more secure than just running this untrusted binary directly on a server full of user uploaded content but I don’t know what level of confidence is should have in wasmtime not having any container escapes possible.
- schemescape 4y agoYes. Consider that Spectre allowed reading browser memory that wasn’t exposed to JavaScript from within the JS sandbox. Something similar probably would have been possible with WASM, if Spectre hadn’t already been found and mitigated. I love capability based limits like this (and in Deno), but they’re not a panacea.
- cesarb 4y ago> You've got some ancient C or C++ source code for the parser, but it hasn't been vetted for security or denial-of-service issues. Compile it to WASM, run it in an isolated runtime, and you can be confident that it won't be able to escape its sandbox This is not just a theory: according to https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/ https://hacks.mozilla.org/2021/12/webassembly-and-back-again... Firefox does exactly that trick with five of its C or C++ dependencies.
- mnemonik 4y agoThere is a section in the linked announcement titled "Why use a WebAssembly Runtime?" that hopefully answers your question.
- fweimer 4y agoIt doesn't say why one should use this WebAssembly implementation, and not (for example) the V8-based implementation that comes with Node.js.
- paulgb 4y agoI wrote a (very surface level) comparison on this last year[1]. If you already have V8 in your environment, it's probably worth using V8, but if you just want to load a wasm interpreter into some Rust code, wasmtime is a much nicer interface to work with and more lightweight. [1] https://paulbutler.org/2021/calling-webassembly-from-rust/ https://paulbutler.org/2021/calling-webassembly-from-rust/ (nb. if I were to write this post today, it would be an omission not to mention the component model)
- eminence32 4y agoThe announcement post has a "Why use a WebAssembly Runtime?" section that might answer your question.
- mikewarot 4y agoIt's a way of running WASM code, which can be anything from anywhere, safely. It only gets access to the folders you let it access as a capability. It gets no access to anything else. So, no matter how evil, or confused, the program is, you aren't risking your entire system. It's the best part of capability based security.
- VyseofArcadia 4y agoA bit like OpenBSD's pledge[0]. Seems a bit of a waste to need a whole runtime for something the OS could provide. [0] https://man.openbsd.org/pledge.2 https://man.openbsd.org/pledge.2
- mtkhaos 4y agoMissing interoperability between web/server. It's moving away from the OS model into something more pure
- VWWHFSfQ 4y agoOperating systems on are becoming increasingly irrelevant.
- pstuart 4y agoIt'll be serverless all the way down...
- paulryanrogers 4y agoUntil you get to the atoms
- jabl 4y agoAnd then turtles. After that it's turtles all the way down.
- encryptluks2 4y ago
- wongarsu 4y agoAnything that wants to run arbitrary, possibly untrusted user-provided code, with good speed and minimal startup time. The big use cases are AWS Lambda-like things (whether that's serving web requests or reacting to event queues), as well as plugin systems for software.
- bfung 4y agoI have the same questions still, after reading all the material and also researching between papers and conference talks. My takeaway so far is: it’s a faster, more flexible, and lighter JVM-like thing. As someone who had written Java Applets from back in the day on the UI side, and written plenty of server side and seen a lot of FaaS successes and failures (more the latter than the former), all the features and use cases map 1:1 - so not really new use cases. Just way better design and implementation (which may make architectures actually end-user usable), w/o money-ed interest. TL;DR, spicy take: “.class file v2”
- enos_feedler 4y ago“Just” without money-ed interest. That is actually huge.
- nlitened 4y ago> Just way better design and implementation Sounds like “far fewer features” to me. Anything that has a lot of features, accumulates a lot if design and implementation compromises (“flaws”)
- brabel 4y ago> it’s a faster, more flexible, and lighter JVM-like thing. Is there any benchmarks showing that wasmtime code can run faster than the equivalent JVM code? How is Wasmtime more flexible than the JVM? It's definitely lighter, for now, but I am not sure that will always be the case with the many WASM proposals.
- bfung 4y agoThe article shows startup time from enter to output being very, very fast. Having rust, go, c, c++, being able to be transpiled to wasm byte code is already more flexible than jvm. Why isn’t there a popular C front end to jvm? -> there’s the flex. Also wasm runs in browser w/o loading applets. Worry about bloat when the project is more mature; there’s no bloat right now and worth exploring.
- 4y ago