From fbb64ee28484464d9d6c684b648b219872f1eafb Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 10 Aug 2022 04:30:54 +0000 Subject: [PATCH] less connections --- web3_proxy/src/app.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web3_proxy/src/app.rs b/web3_proxy/src/app.rs index 2536dd3f..a00ee74d 100644 --- a/web3_proxy/src/app.rs +++ b/web3_proxy/src/app.rs @@ -86,15 +86,15 @@ pub async fn flatten_handles( /// Connect to the database and run migrations pub async fn get_migrated_db( db_url: String, - min_connections: u32, + max_connections: u32, ) -> anyhow::Result { let mut db_opt = sea_orm::ConnectOptions::new(db_url); // TODO: load all these options from the config file. i think mysql default max is 100 // TODO: sqlx logging only in debug. way too verbose for production db_opt - .max_connections(99) - .min_connections(min_connections) + .min_connections(1) + .max_connections(max_connections) .connect_timeout(Duration::from_secs(8)) .idle_timeout(Duration::from_secs(8)) .max_lifetime(Duration::from_secs(60)) @@ -185,9 +185,9 @@ impl Web3ProxyApp { )> { // first, we connect to mysql and make sure the latest migrations have run let db_conn = if let Some(db_url) = app_config.shared.db_url { - let min_connections = num_workers.try_into()?; + let max_connections = num_workers.try_into()?; - let db = get_migrated_db(db_url, min_connections).await?; + let db = get_migrated_db(db_url, max_connections).await?; Some(db) } else {