mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-12 14:10:19 +08:00
perf(gateway): raise default server pool floor
This commit is contained in:
@@ -195,6 +195,35 @@ mod tests {
|
||||
assert_eq!(background.pool.min_connections, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_pool_split_gives_default_small_server_more_foreground_capacity() {
|
||||
let config = GatewayDataConfig::from_database_config(
|
||||
SqlDatabaseConfig::new(
|
||||
DatabaseDriver::Postgres,
|
||||
"postgres://localhost/aether",
|
||||
SqlPoolConfig {
|
||||
min_connections: 4,
|
||||
max_connections: 32,
|
||||
..SqlPoolConfig::default()
|
||||
},
|
||||
)
|
||||
.expect("database config should be valid"),
|
||||
);
|
||||
|
||||
let (foreground, background) = config.split_runtime_pools_with_background_max(None);
|
||||
let foreground = foreground.database().expect("foreground database");
|
||||
let background = background
|
||||
.expect("background database config")
|
||||
.database()
|
||||
.expect("background database")
|
||||
.clone();
|
||||
|
||||
assert_eq!(foreground.pool.max_connections, 26);
|
||||
assert_eq!(background.pool.max_connections, 6);
|
||||
assert_eq!(foreground.pool.min_connections, 4);
|
||||
assert_eq!(background.pool.min_connections, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_pool_split_can_be_disabled_or_degrade_for_single_connection() {
|
||||
let mut database = SqlDatabaseConfig::sqlite_default();
|
||||
|
||||
@@ -261,7 +261,7 @@ const DEFAULT_SQLITE_POOL_MAX_CONNECTIONS: u32 = 1;
|
||||
const AUTO_SERVER_SQL_POOL_CONNECTIONS_PER_CPU: u32 = 4;
|
||||
const AUTO_SERVER_SQL_POOL_MIN_CONNECTIONS_FLOOR: u32 = 4;
|
||||
const AUTO_SERVER_SQL_POOL_MIN_CONNECTIONS_CAP: u32 = 16;
|
||||
const AUTO_SERVER_SQL_POOL_MAX_CONNECTIONS_FLOOR: u32 = 20;
|
||||
const AUTO_SERVER_SQL_POOL_MAX_CONNECTIONS_FLOOR: u32 = 32;
|
||||
const AUTO_SERVER_SQL_POOL_MAX_CONNECTIONS_CAP: u32 = 100;
|
||||
const DEFAULT_USAGE_QUEUE_WORKERS_CAP: usize = 8;
|
||||
const AUTO_USAGE_QUEUE_WORKERS_MIN: usize = 2;
|
||||
@@ -2837,7 +2837,11 @@ mod tests {
|
||||
fn gateway_data_pool_cpu_sizing_examples() {
|
||||
let two_cpu = automatic_sql_pool_config_for_parallelism(DatabaseDriver::Postgres, 2);
|
||||
assert_eq!(two_cpu.min_connections, 4);
|
||||
assert_eq!(two_cpu.max_connections, 20);
|
||||
assert_eq!(two_cpu.max_connections, 32);
|
||||
|
||||
let four_cpu = automatic_sql_pool_config_for_parallelism(DatabaseDriver::Postgres, 4);
|
||||
assert_eq!(four_cpu.min_connections, 4);
|
||||
assert_eq!(four_cpu.max_connections, 32);
|
||||
|
||||
let eight_cpu = automatic_sql_pool_config_for_parallelism(DatabaseDriver::Postgres, 8);
|
||||
assert_eq!(eight_cpu.min_connections, 8);
|
||||
|
||||
Reference in New Issue
Block a user