grpc / grpc/grpc-rust

Add Server::max_concurrent_connections(usize)

Open
#2,094 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

Add `tonic::transport::Server::max_concurrent_connections(limit: usize)` which limits the number of concurrent connections that are allowed to be served at the same time. If we reach this limit, then the server will wait until a connection drops before calling `.accept()` on the socket again.

The change would require guarding the `listener.accept()` call with a semaphore [here](https://github.com/hyperium/tonic/blob/87f195b5fd24efe96e5f8010fada0c3e75225976/tonic/src/transport/server/mod.rs#L612) and passing the permit of that semaphore to `serve_connection` [here](https://github.com/hyperium/tonic/blob/87f195b5fd24efe96e5f8010fada0c3e75225976/tonic/src/transport/server/mod.rs#L638).

I'm happy to make a PR if the contribution is welcome

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.