Reduce backend per-upload CPU to relieve upload timeouts

The Node main thread was saturated at about 39 uploads/s, overflowing the
listen queue so uploads timed out connecting from nginx.

- Enable keepAlive on the S3 agent; every upload did a full TLS handshake
- Remove OpenTelemetry tracing
- Cache the system key lookup for 60s
- Use lean queries when listing calls
- Serialize each call once in notify_clients, not per recipient
- Add an nginx upstream keepalive pool, and hold Node's keepAliveTimeout
  above it so nginx never reuses a connection Node has closed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Luke Berndt
2026-11-09 18:06:48 -05:00
parent c0492ebf53
commit 6825aaf9a4
6 changed files with 220 additions and 290 deletions

View File

@@ -1,5 +1,18 @@
limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s;
# Only send "Connection: upgrade" for real WebSocket requests, so ordinary
# requests can reuse the upstream keepalive pool.
map $http_upgrade $backend_connection {
default upgrade;
'' '';
}
upstream backend_api {
server backend:3005;
keepalive 64;
keepalive_timeout 60s;
}
server {
listen 80;
server_name account.${DOMAIN_NAME} api.${DOMAIN_NAME} admin.${DOMAIN_NAME} www.${DOMAIN_NAME} ${DOMAIN_NAME};
@@ -87,10 +100,10 @@ server {
location / {
proxy_pass http://backend:3005;
proxy_pass http://backend_api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Connection $backend_connection;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
include /etc/nginx/proxy.conf;

View File

@@ -1,4 +1,17 @@
# Only send "Connection: upgrade" for real WebSocket requests, so ordinary
# requests can reuse the upstream keepalive pool.
map $http_upgrade $backend_connection {
default upgrade;
'' '';
}
upstream backend_api {
server backend:3005;
keepalive 64;
keepalive_timeout 60s;
}
server {
listen 80;
@@ -89,11 +102,11 @@ server {
}
location / {
proxy_pass http://backend:3005;
proxy_pass http://backend_api;
include /etc/nginx/proxy.conf;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Connection $backend_connection;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
access_log /dev/stdout main;