From de19c3fa5d4b1d5ca059373107511239bbcf2d95 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Thu, 5 Dec 2024 01:11:14 +0100 Subject: [PATCH] Increase the number of database concurrent connection --- backend/src/consts.rs | 2 ++ backend/src/data/db.rs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/consts.rs b/backend/src/consts.rs index 386ffb7..a8f3fff 100644 --- a/backend/src/consts.rs +++ b/backend/src/consts.rs @@ -18,3 +18,5 @@ pub const SEND_EMAIL_TIMEOUT: Duration = Duration::from_secs(60); // HTTP headers, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers. // Common headers can be found in 'axum::http::header' (which is a re-export of the create 'http'). pub const REVERSE_PROXY_IP_HTTP_FIELD: &str = "x-real-ip"; // Set by the reverse proxy (Nginx). + +pub const MAX_DB_CONNECTION: u32 = 1024; diff --git a/backend/src/data/db.rs b/backend/src/data/db.rs index 0820cb5..5182fd3 100644 --- a/backend/src/data/db.rs +++ b/backend/src/data/db.rs @@ -119,7 +119,13 @@ impl Connection { .pragma("foreign_keys", "ON") .pragma("synchronous", "NORMAL"); - Self::create_connection(SqlitePoolOptions::new().connect_with(options).await?).await + Self::create_connection( + SqlitePoolOptions::new() + .max_connections(consts::MAX_DB_CONNECTION) + .connect_with(options) + .await?, + ) + .await } async fn create_connection(pool: Pool) -> Result { -- 2.45.2