Skip to content

RPC: Add a requests per second limit #398

Description

@mcintyre94

Many RPC providers have a limit on requests per second, meaning apps need to control how they send RPC requests. Kit and client plugins can abstract RPC requests, making it difficult to control how quickly requests are sent or how many are sent per second.

The solution for this in Kit is to use a custom transport: https://github.com/anza-xyz/kit/#custom-rpc-transports - this can affect all requests to an RPC. A custom transport could restrict an RPC to N requests per second and queue requests over this limit, to prevent an app receiving rate limits from the RPC service.

We could add support for this to our RPC plugin, eg. a maxRequestsPerSecond parameter. If passed, we would create a simple custom transport enforcing that limit, and use it for the created RPC. This would then automatically apply the rate limit to client.rpc regardless how it is called.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions