Skip to content

Limit the number of concurrent outbound HTTP requests #3281

@rylev

Description

@rylev

I'm trying to limit the number of outbound requests guests can make to make sure no single guest can exhaust resources on the host system. Ideally, I'd be able to limit the number of client ports used by a guest application because I believe this (besides open file descriptors) is the resource I'm really worried about exhausting. However, I believe that this number is buried deep in the internals of hyper, and we don't really have access to it from inside Spin.

So the next best idea is to just limit the number of outbound requests which should be a fairly close approximation of what we want. I have a branch with a POC implementation that just adds an AtomicUsize to the instance state and increment/decrements this number before and after each request. Additionally it checks this number against some configured max and rejects the request if we're currently doing too many.

Does this sound like a good approach? If so, I will clean up the branch and open a PR. Otherwise, I'd love to brainstorm a better approach.

cc @dicej who recently added connection pooling and @lann who I know will be interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions