mirror of
https://github.com/gadgethd/ukmesh.git
synced 2026-09-10 00:55:33 +00:00
Backend: - getViableLinks: replace correlated EXISTS subquery (2m 49s!) with CTE-based join on pre-computed node set (39ms) — eliminates WS initial state timeouts - WS initial state: switch from getLastNPackets (1,872ms, 24h correlated subqueries) to getRecentPackets (16ms, 5-min CTE) — cold connect now 30ms - Debounce emitNode/emitNodeUpsert with 500ms window to coalesce rapid advert bursts before publishing to Redis (10-100x fewer publishes during active periods) - Pre-normalise node IDs to lowercase at broadcast time; remove per-client toLowerCase() allocations in shouldSendMessage (~200 allocs/sec eliminated) - Cache /api/path-beta/history (60s TTL) and /api/coverage (30s TTL) - Add 10-min TTL to resolveCache to prevent multi-day unbounded growth - Fix LOWER() on node_status_samples queries suppressing index use - Add Express compression() middleware; add gzip to nginx.website.conf - Increase viableLinksCache TTL 30s→5min, INITIAL_STATE_TTL 30s→60s - Pre-warm initial state cache at startup for teesside+ukmesh - Add compression package dependency Frontend: - Lazy-load coverage (26MB GeoJSON) — only fetch when coverage toggle is on, not on every page mount regardless of filter state - Remove standalone 30s setInterval from useDashboardStats; feed stats from App.tsx consolidated poll instead (-1 HTTP request per 30s) - Pre-compute DeckGL packet-history segment colour+width inside useMemo; getColor/getWidth become pure property lookups (~6000 log() calls/sec removed) - DeckGLOverlay.tsx: add HistorySegmentWithColor type for pre-computed values Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.9 KiB
Plaintext
61 lines
1.9 KiB
Plaintext
server {
|
|
listen 80;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
|
|
# Gzip compression — critical for large API responses (coverage ~26 MB → ~2-3 MB)
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
|
gzip_min_length 256;
|
|
|
|
# Proxy API calls through to the app service so live stats work
|
|
location /api/ {
|
|
set $backend_api_upstream http://backend:3000;
|
|
proxy_pass $backend_api_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Proxy WebSocket connections to backend
|
|
location /ws/ {
|
|
set $backend_ws_upstream http://backend:3000;
|
|
proxy_pass $backend_ws_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
location /ws {
|
|
set $backend_ws_upstream http://backend:3000;
|
|
proxy_pass $backend_ws_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
|
|
# SPA fallback — all routes serve index.html
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
}
|