Avoiding destroying connections with existing leaders

This commit is contained in:
Godmode Galactus 2023-07-19 11:08:27 +02:00
parent 5ec8ba4aee
commit 48d26eac15
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
2 changed files with 6 additions and 14 deletions

View File

@ -101,7 +101,7 @@ impl LiteBridge {
max_number_of_connections: 10,
unistream_timeout: Duration::from_millis(500),
write_timeout: Duration::from_secs(1),
number_of_transactions_per_unistream: 10,
number_of_transactions_per_unistream: 8,
},
};

View File

@ -146,19 +146,11 @@ impl ActiveConnection {
}
}
if txs.len() >= number_of_transactions_per_unistream - 1 {
// queue getting full and a connection poll is getting slower
// add more connections to the pool
if connection_pool.len() < max_number_of_connections {
connection_pool.add_connection().await;
NB_QUIC_CONNECTIONS.inc();
}
} else if txs.len() == 1 {
// low traffic / reduce connection till minimum 1
if connection_pool.len() > 1 {
connection_pool.remove_connection().await;
NB_QUIC_CONNECTIONS.dec();
}
// queue getting full and a connection poll is getting slower
// add more connections to the pool
if connection_pool.len() < max_number_of_connections {
connection_pool.add_connection().await;
NB_QUIC_CONNECTIONS.inc();
}
let task_counter = task_counter.clone();