Skip to content

Conversation

@dicej
Copy link
Contributor

@dicej dicej commented Oct 28, 2025

This makes use of the new wasmtime_wasi_http::handler::ProxyHandler utility, which provides both serial and concurrent instance reuse.

We could hypothetically enable opt-in serial reuse for WASIp2 components as well using the same pattern (which is what wasmtime serve does), but I'll leave that for a follow-up PR, if desired.

@dicej dicej requested review from lann and tschneidereit October 28, 2025 14:34
tracing::trace!("Adding archive layer for all files in source {:?}", &source);
let working_dir = tempfile::tempdir()?;
let archive_path = crate::utils::archive(source, &working_dir.into_path())
let archive_path = crate::utils::archive(source, &working_dir.keep())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a clippy deprecation warning.

@tschneidereit
Copy link
Contributor

Very cool, I'm really glad this seems to have worked out without too much trouble!

This hard-codes the configuration values (max reuse count = 128, max concurrent reuse count = 16, idle timeout = 1s) for now. Once we've decided where these values should be configured (e.g. in the spin.toml manifest, in the runtime
config, or at runtime via the component itself), we can support that. See WebAssembly/wasi-http#190 for related discussion.

I think this should be configurable via runtime config, plus env vars and/or CLI options, but not spin.toml: the runtime should set its upper limits for reuse / timeouts, with individual components being able to reduce down from there by signaling backpressure / exiting.

The wasi-http discussion is of course relevant, but I think shouldn't really change anything about these config settings in and of themselves.

@itowlson
Copy link
Collaborator

At one point we discussed exposing app developers to a mix of "new instance" and "reused instance" in the CLI in order to help developers detect latent reuse bugs, e.g. by randomly deciding to biff the current instance, or by having a default reuse configuration that developers would hit a mix in any non-trivial testing. Is that on the agenda?

@tschneidereit
Copy link
Contributor

oh, good point: I had forgotten about that. And yes, we should definitely make these values configurable as ranges, within which we randomize

@dicej
Copy link
Contributor Author

dicej commented Oct 30, 2025

Sounds good. I'm on a roll right now adding async support to componentize-py, but when I reach a stopping point I'll come back to this and add runtime config support, including ranges for random selection.

This makes use of the new `wasmtime_wasi_http::handler::ProxyHandler` utility,
which provides both serial and concurrent instance reuse.

We could hypothetically enable opt-in serial reuse for WASIp2 components as well
using the same pattern (which is what `wasmtime serve` does), but I'll leave
that for a follow-up PR, if desired.

This hard-codes the configuration values (max reuse count = 128, max concurrent
reuse count = 16, idle timeout = 1s) for now.  Once we've decided where these
values should be configured (e.g. in the spin.toml manifest, in the runtime
config, or at runtime via the component itself), we can support that.  See
WebAssembly/wasi-http#190 for related discussion.

Signed-off-by: Joel Dice <[email protected]>
@dicej
Copy link
Contributor Author

dicej commented Nov 10, 2025

I just pushed an update that adds the configuration support we discussed. I noticed that the existing mechanism to configure trigger-http is via clap CLI arguments rather than a runtime config file, so I followed that precedent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants