diff --git a/src/cli/rpc.rs b/src/cli/rpc.rs index 6658b685d..98af54455 100644 --- a/src/cli/rpc.rs +++ b/src/cli/rpc.rs @@ -51,6 +51,15 @@ pub struct RpcArgs { default_value = "20" )] timeout_seconds: String, + + /// Maximum number of concurrent connections + #[arg( + long = "rpc.max_connections", + name = "rpc.max_connections", + env = "RPC_MAX_CONNECTIONS", + default_value = "100" + )] + max_connections: u32, } impl RpcArgs { @@ -99,6 +108,7 @@ impl RpcArgs { sim_settings, estimation_settings, rpc_timeout: Duration::from_secs(self.timeout_seconds.parse()?), + max_connections: self.max_connections, mempool_configs, }) } diff --git a/src/rpc/task.rs b/src/rpc/task.rs index bc74bb4b9..0dac609f0 100644 --- a/src/rpc/task.rs +++ b/src/rpc/task.rs @@ -51,6 +51,7 @@ pub struct Args { pub sim_settings: simulation::Settings, pub estimation_settings: estimation::Settings, pub rpc_timeout: Duration, + pub max_connections: u32, pub mempool_configs: HashMap, } @@ -146,6 +147,7 @@ impl Task for RpcTask { let server = ServerBuilder::default() .set_logger(RpcMetricsLogger) .set_middleware(service_builder) + .max_connections(self.args.max_connections) .http_only() .build(addr) .await?;