mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 09:09:07 -05:00
feat: configurable blocking threads
This commit is contained in:
parent
8598e443d8
commit
d10348f7e1
|
@ -78,6 +78,9 @@ reject_future_seconds = 1800
|
||||||
# defaults to unlimited (subject to subscription limits).
|
# defaults to unlimited (subject to subscription limits).
|
||||||
#db_conns_per_client = 0
|
#db_conns_per_client = 0
|
||||||
|
|
||||||
|
# Limit blocking threads used for database connections. Defaults to 64.
|
||||||
|
#max_blocking_threads = 64
|
||||||
|
|
||||||
# Limit the maximum size of an EVENT message. Defaults to 128 KB.
|
# Limit the maximum size of an EVENT message. Defaults to 128 KB.
|
||||||
# Set to 0 for unlimited.
|
# Set to 0 for unlimited.
|
||||||
#max_event_bytes = 131072
|
#max_event_bytes = 131072
|
||||||
|
|
|
@ -54,6 +54,7 @@ pub struct Limits {
|
||||||
pub messages_per_sec: Option<u32>, // Artificially slow down event writing to limit disk consumption (averaged over 1 minute)
|
pub messages_per_sec: Option<u32>, // Artificially slow down event writing to limit disk consumption (averaged over 1 minute)
|
||||||
pub subscriptions_per_min: Option<u32>, // Artificially slow down request (db query) creation to prevent abuse (averaged over 1 minute)
|
pub subscriptions_per_min: Option<u32>, // Artificially slow down request (db query) creation to prevent abuse (averaged over 1 minute)
|
||||||
pub db_conns_per_client: Option<u32>, // How many concurrent database queries (not subscriptions) may a client have?
|
pub db_conns_per_client: Option<u32>, // How many concurrent database queries (not subscriptions) may a client have?
|
||||||
|
pub max_blocking_threads: usize,
|
||||||
pub max_event_bytes: Option<usize>, // Maximum size of an EVENT message
|
pub max_event_bytes: Option<usize>, // Maximum size of an EVENT message
|
||||||
pub max_ws_message_bytes: Option<usize>,
|
pub max_ws_message_bytes: Option<usize>,
|
||||||
pub max_ws_frame_bytes: Option<usize>,
|
pub max_ws_frame_bytes: Option<usize>,
|
||||||
|
@ -218,6 +219,7 @@ impl Default for Settings {
|
||||||
messages_per_sec: None,
|
messages_per_sec: None,
|
||||||
subscriptions_per_min: None,
|
subscriptions_per_min: None,
|
||||||
db_conns_per_client: None,
|
db_conns_per_client: None,
|
||||||
|
max_blocking_threads: 64,
|
||||||
max_event_bytes: Some(2 << 17), // 128K
|
max_event_bytes: Some(2 << 17), // 128K
|
||||||
max_ws_message_bytes: Some(2 << 17), // 128K
|
max_ws_message_bytes: Some(2 << 17), // 128K
|
||||||
max_ws_frame_bytes: Some(2 << 17), // 128K
|
max_ws_frame_bytes: Some(2 << 17), // 128K
|
||||||
|
|
|
@ -245,6 +245,14 @@ pub fn start_server(settings: Settings, shutdown_rx: MpscReceiver<()>) -> Result
|
||||||
let rt = Builder::new_multi_thread()
|
let rt = Builder::new_multi_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.thread_name("tokio-ws")
|
.thread_name("tokio-ws")
|
||||||
|
// limit concurrent SQLite blocking threads
|
||||||
|
.max_blocking_threads(settings.limits.max_blocking_threads)
|
||||||
|
.on_thread_start(|| {
|
||||||
|
debug!("started new thread");
|
||||||
|
})
|
||||||
|
.on_thread_stop(|| {
|
||||||
|
debug!("stopping thread");
|
||||||
|
})
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// start tokio
|
// start tokio
|
||||||
|
|
Loading…
Reference in New Issue
Block a user