diff --git a/CHANGELOG.md b/CHANGELOG.md index f50121804636..277b4c110422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ - [#6471](https://github.com/ChainSafe/forest/pull/6471): Moved `forest-tool state` subcommand to `forest-dev`. +- [#6527](https://github.com/ChainSafe/forest/issues/6527): Increased the maximum number of allowed connections to the RPC server to 1000. This can be further configured via the `FOREST_RPC_MAX_CONNECTIONS` environment variable. + ### Removed ### Fixed diff --git a/docs/docs/users/reference/env_variables.md b/docs/docs/users/reference/env_variables.md index 286f3e644aa8..cf28d14de39c 100644 --- a/docs/docs/users/reference/env_variables.md +++ b/docs/docs/users/reference/env_variables.md @@ -20,6 +20,7 @@ process. | `FOREST_FORCE_TRUST_PARAMS` | 1 or true | false | 1 | Trust the parameters downloaded from the Cloudflare/IPFS | | `IPFS_GATEWAY` | URL | `https://proofs.filecoin.io/ipfs/` | `https://proofs.filecoin.io/ipfs/` | The IPFS gateway to use for downloading proofs parameters | | `FOREST_RPC_DEFAULT_TIMEOUT` | Duration (in seconds) | 60 | 10 | The default timeout for RPC calls | +| `FOREST_RPC_MAX_CONNECTIONS` | positive integer | 1000 | 42 | Maximum number of allowed connections for the RPC server | | `FOREST_MAX_CONCURRENT_REQUEST_RESPONSE_STREAMS_PER_PEER` | positive integer | 10 | 10 | the maximum concurrent streams per peer for request-response-based p2p protocols | | `FOREST_BLOCK_DELAY_SECS` | positive integer | Depends on the network | 30 | Duration of each tipset epoch | | `FOREST_PROPAGATION_DELAY_SECS` | positive integer | Depends on the network | 20 | How long to wait for a block to propagate through the network | diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 6986ae7e05aa..14a168f514c6 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -466,6 +466,15 @@ static DEFAULT_REQUEST_TIMEOUT: LazyLock = LazyLock::new(|| { .unwrap_or(Duration::from_secs(60)) }); +/// Default maximum connections for the RPC server. This needs to be high enough to +/// accommodate the regular usage for RPC providers. +static DEFAULT_MAX_CONNECTIONS: LazyLock = LazyLock::new(|| { + env::var("FOREST_RPC_MAX_CONNECTIONS") + .ok() + .and_then(|it| it.parse().ok()) + .unwrap_or(1000) +}); + const MAX_REQUEST_BODY_SIZE: u32 = 64 * 1024 * 1024; const MAX_RESPONSE_BODY_SIZE: u32 = MAX_REQUEST_BODY_SIZE; @@ -565,6 +574,7 @@ where // Default size (10 MiB) is not enough for methods like `Filecoin.StateMinerActiveSectors` .max_request_body_size(MAX_REQUEST_BODY_SIZE) .max_response_body_size(MAX_RESPONSE_BODY_SIZE) + .max_connections(*DEFAULT_MAX_CONNECTIONS) .set_id_provider(RandomHexStringIdProvider::new()) .build(), )