Skip to content

Connection limits#3552

Open
rylev wants to merge 15 commits into
mainfrom
connection-limits
Open

Connection limits#3552
rylev wants to merge 15 commits into
mainfrom
connection-limits

Conversation

@rylev
Copy link
Copy Markdown
Collaborator

@rylev rylev commented Jun 2, 2026

This PR is probably best reviewed commit by commit. Each factor's changes are largely independent and follow the same pattern.

This adds connection limits (both per factor and global) for the following factors (which originally had separate PRs which have been closed in favor of a single PR):

Additionally the global connection limit is connected to the existing outbound http connection limiting introduced in #3285. The runtime config toml has also been updated to be consistent across all factors while retaining the now deprecated existing toml naming for backwards compatibility.

Open Issues/Questions

  • I was not able to wrap the wasi P3 Socket implementation in a wrapper type that could hold on to a ConnectionSemaphore. I may need to talk with @dicej about introducing changes in wasmtime-wasi to allow this.
  • The wasi socket connections error immediately when no quota is available where as all other implementations .await for quote blocking the guest from making progress. Should we always immediately error so that guests can decide what to do when no capacity is available? We treated sockets differently because waiting would risk deadlock if a component holds sockets open across async yield points.
  • KV is not limited. Should we limit KV with the same mechanism, a different mechanism, or not at all?

Breaking changes

This does contain one breaking change (beyond factor APIs which I believe we do not have any stability guarantees at this point): the outbound_http.concurrent_connection_permits_acquired metric has been renamed to outbound_connection_permits_acquired with the label kind set to outbound_http. Maintaining backward compatibility here is ugly but doable if we believe it is important.

Comment thread crates/connection-semaphore/src/lib.rs Outdated
lann

This comment was marked as resolved.

@dicej
Copy link
Copy Markdown
Contributor

dicej commented Jun 3, 2026

I was not able to wrap the wasi P3 Socket implementation in a wrapper type that could hold on to a ConnectionSemaphore. I may need to talk with @dicej about introducing changes in wasmtime-wasi to allow this.

What issues did you run into there? I'm happy to start working on any changes needed.

@rylev
Copy link
Copy Markdown
Collaborator Author

rylev commented Jun 3, 2026

@dicej you can see code plus a print out of the compilation errors in this commit. Essentially there's no way to make the store.with_getter call to work since the generic T is just a plain generic that the implementor cannot set.

rylev added 15 commits June 3, 2026 17:51
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
…nces

Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
…it times

Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
Signed-off-by: Ryan Levick <rlevick@akamai.com>
@rylev rylev force-pushed the connection-limits branch from 52d2645 to 3e9fb87 Compare June 3, 2026 16:06
@rylev rylev requested a review from lann June 3, 2026 16:06
@dicej
Copy link
Copy Markdown
Contributor

dicej commented Jun 3, 2026

@dicej you can see code plus a print out of the compilation errors in this commit. Essentially there's no way to make the store.with_getter call to work since the generic T is just a plain generic that the implementor cannot set.

Thanks, I'll check out that commit and play around with it.

@rylev
Copy link
Copy Markdown
Collaborator Author

rylev commented Jun 5, 2026

I was not able to wrap the wasi P3 Socket implementation in a wrapper type that could hold on to a ConnectionSemaphore. I may need to talk with @dicej about introducing changes in wasmtime-wasi to allow this.

Update: thanks to @dicej and @alexcrichton for helping figure this out. With the addition of bytecodealliance/wasmtime#13549, we will be able to support this. The code for that can be see in https://github.com/dicej/spin/tree/connection-limits. We'll want to wait until the linked changes land in a release of wasmtime to adopt this, but the path forward is now clear.

@lann
Copy link
Copy Markdown
Collaborator

lann commented Jun 5, 2026

Do we have an issue tracking p3 socket support?

@rylev
Copy link
Copy Markdown
Collaborator Author

rylev commented Jun 5, 2026

Do we have an issue tracking p3 socket support?

I do not see any.

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