fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.27k stars 251 forks source link

Spin should block on accepting a request when at maximum concurrent instance limit #1937

Open lann opened 1 year ago

lann commented 1 year ago

Currently Spin returns an error "maximum concurrent instance limit of 1000 reached" when more than 1000 (by default) concurrent requests are made. Rather than failing, Spin should block new requests while waiting for instances to complete, providing backpressure.

lann commented 1 year ago

This is a little tricky to implement as wasmtime doesn't expose the current live instance count and even if it did we would need some signal that the count has changed or would need to awkwardly poll the count in a loop.

We could alternatively track instances ourselves with some wrapper of Instances that tracks the count on new/drop.