-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasmtime serve: allow component reuse, serving > 1 request per instance #9542
Comments
Wizer is intended to help with that. It takes a wasm module, runs the initialization code in it and then produces a new wasm module with all initialization already done. It does require some minor changes to your own code to indicate when initialization is done though. |
I've got an old branch of mine that I was experimenting with for this which I just rebased to dust it off a bit. There's been some discussion amongst folks historically about this and one of the concerns historically has been about certain instances either requiring reuse or explicitly not supporting reuse and how to surface that in the component itself. Those discussions never reached a firm conclusion one way or another though which is why it's never landed as a feature yet. I'll note that I'm not intimately familiar with the concerns here and I'm mostly a proxy for other (e.g. @lukewagner I think knows much more about the concerns both ways here). Otherwise I'll definitely echo @bjorn3's idea of wizer. I suspect @ydnar you're already familiar with it but for anyone else who happens upon this in the future we've done a lot of work in Wasmtime to make instantiation as fast as possible through tools like wizer, APIs like I'd also still acknowledge though that even with all the tools in the toolbox I think there's still real situations where instance-per-request isn't fast enough. Personally I think we should support a flag like this on the command line (the default being perhaps a separate question). |
Thanks! Wizer works to a point, but cannot help amortize long-lived connections to upstream servers (like databases). Echoing some live conversations with @alexcrichton and @lukewagner: I think the design of wasi:http/proxy implies reuse, but does not mandate it. A host can choose to not reuse, and a guest can exit to indicate it doesn't want to be reused. My specific use case: I'm working on a talk for WasmCon with @Mossaka, demoing a Go implementation of wasi-http, and would love to show off the new go:wasmexport feature that integrates with goroutines and the runtime. |
FWIW, a summary of the idea proposed in component-model/#307 is:
This would seem to me to balance the many subtle competing concerns. |
A couple challenges I see with this approach:
I’d favor an alternative, where:
|
Hrm, I'm not sure if what you're proposing is any different...
These are already the case (both in the component model in general and explicitly in WASI HTTP's doc comments).
This too is also already possible. (I'll point out that, since
This is what the "reuse hint" is. I don't know if you're imagining some more dynamic indication (calling an imported function or something), but that's no less work (perhaps more) and has less up-front information that can be used by the runtime/platform to provide useful diagnostics to the developer. I also don't know if you're worrying about what's expressible in the core webassembly build target, but we can always express the reuse hint as some symbolic core wasm import or export that Lastly, I don't know if you're proposing to change the default behavior of |
Thanks for breaking down the overlapping problem spaces here!
|
Thanks for filing a feature request! Please fill out the TODOs below.
Feature
I’d like an option (or default) for
wasmtime serve
to reuse a component for multiple requests. e.g.wasmtime serve --reuse
orwasmtime serve --no-reuse
Benefit
Amortize costly runtime or application initialization across multiple requests.
Implementation
Not sure!
Alternatives
Use a different
wasi-http
host other thanwasmtime
in development that supports instance reuse?The text was updated successfully, but these errors were encountered: