Scale nostr_connect workers and isolate nostr_rpc from listeners

NostrConnectListenerJob holds a worker thread for up to CONNECT_TTL (5 min)
waiting on relay websockets, and it shared one 4-thread worker group with
NostrSignEventJob/NostrLogoutJob (nostr_rpc). A handful of concurrent signer
logins could therefore starve signing behind the listeners.

Split the two queues into separate worker groups and make their thread counts
env-tunable (NOSTR_CONNECT_THREADS, default 24; NOSTR_RPC_THREADS, default 4).
The listeners are IO-blocked (async fibers, GVL-free waits), so threads rather
than processes are the cheap way to add capacity.

Production must size DB_POOL to at least NOSTR_CONNECT_THREADS, since each
worker thread holds a database connection for the duration of its job.
This commit is contained in:
raucao committed 2026-11-27 17:06:03 +04:00
1 parent d67e6e90dd
commit 612d275b58
1 file changed
+16 -4
+16 -4
View File
@@ -7,21 +7,33 @@ default: &default
threads: 3
processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
polling_interval: 0.1
- queues: [nostr_connect, nostr_rpc]
threads: 4
# NIP-46 signing round-trips block up to 90s, so keep them off the
# long-blocking listener pool below.
- queues: [nostr_rpc]
threads: <%= ENV.fetch("NOSTR_RPC_THREADS", 4) %>
processes: 1
polling_interval: 0.1
# NostrConnectListenerJob holds a worker thread for up to
# NostrSignerSession::CONNECT_TTL (5 min) waiting on relay websockets
# (it aborts within ~60s once the browser stops polling status). These
# are IO-blocked, so scale with cheap threads rather than processes.
- queues: [nostr_connect]
threads: <%= ENV.fetch("NOSTR_CONNECT_THREADS", 24) %>
processes: <%= ENV.fetch("NOSTR_CONNECT_CONCURRENCY", 1) %>
polling_interval: 0.1
development:
<<: *default
workers:
- queues: [default, nostr]
threads: 1
- queues: [nostr_connect, nostr_rpc]
- queues: [nostr_rpc]
threads: 2
- queues: [nostr_connect]
threads: 4
test:
<<: *default
production:
<<: *default
<<: *default