perf(console): faster dashboard for organizations with thousands of monitors #164

Merged
Sebi merged 2 commits from perf/dashboard-large-orgs into main 2026-11-26 20:55:56 +00:00
Owner

The dashboard of an organization with 3,500 monitors took 4.4 s in production (582 KB page).

Reproduced locally with 3,500 monitors in 4 regions, 2 groups and 24 h of results:

  • Range picker (earliestData) dropped: it queried the real-time daily aggregate, which aggregates the not yet materialized raw results (up to ~2 h of every monitor and region) on every request, plus up to one index lookup per monitor. The oldest monitor's created_at bounds the offered ranges now.
  • Sorting computed each row's key (fmt.Sprintf, uuid.Parse, ToLower) per comparison and swapped large structs; keys are computed once and rows moved once. 40–60 ms → ~5 ms.
  • Queries behind the monitor list run in four parallel transactions; the database is remote in production.
  • GET /api/v1/org/monitors reads latest results for the page's monitors instead of the whole organization on every page.
  • Server-Timing header on the dashboard (load, arrange, bars, rest) and a slow console page warning with the steps when it takes ≥ 1 s, so production timings are visible without touching the database.

Local dashboard: ~400–600 ms → ~190 ms.

Still raw: the 24 h bars (≈ 576k rows for ~100 shown monitors); the Server-Timing in production will tell whether they need the hourly aggregate.

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

The dashboard of an organization with 3,500 monitors took 4.4 s in production (582 KB page). Reproduced locally with 3,500 monitors in 4 regions, 2 groups and 24 h of results: - **Range picker** (`earliestData`) dropped: it queried the real-time daily aggregate, which aggregates the not yet materialized raw results (up to ~2 h of every monitor and region) on every request, plus up to one index lookup per monitor. The oldest monitor's `created_at` bounds the offered ranges now. - **Sorting** computed each row's key (`fmt.Sprintf`, `uuid.Parse`, `ToLower`) per comparison and swapped large structs; keys are computed once and rows moved once. 40–60 ms → ~5 ms. - **Queries** behind the monitor list run in four parallel transactions; the database is remote in production. - **`GET /api/v1/org/monitors`** reads latest results for the page's monitors instead of the whole organization on every page. - **Server-Timing** header on the dashboard (`load`, `arrange`, `bars`, `rest`) and a `slow console page` warning with the steps when it takes ≥ 1 s, so production timings are visible without touching the database. Local dashboard: ~400–600 ms → ~190 ms. Still raw: the 24 h bars (≈ 576k rows for ~100 shown monitors); the Server-Timing in production will tell whether they need the hourly aggregate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 1 commit 2026-11-26 20:35:31 +00:00
perf(console): faster dashboard for organizations with thousands of monitors
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m12s
ci / test (pull_request) Successful in 12m47s
ci / build (pull_request) Canceled after 1m41s
ci / image (pull_request) Canceled after 0s
ec33ef5c56
- The range picker no longer looks for the first result: on the real-time
  daily aggregate that aggregated the organization's recent raw results
  on every request. The oldest monitor's creation bounds the ranges now.
- Sorting worked out each row's key per comparison; it does so once now
  and moves each row once (40-60 ms to 5 ms for 3,500 monitors).
- The queries behind the monitor list run in parallel.
- The monitor API reads the latest results of the page's monitors only.
- The dashboard reports its steps in a Server-Timing header and logs
  them when it takes a second or more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Author
Owner

Added: 24 h bars come from the real-time hourly aggregate (24 hourly bars instead of 48 half-hourly ones). Locally with 3,500 monitors: bars 150–230 ms → 18 ms, page 570 KB → 335 KB, dashboard ~170 ms.

Added: 24 h bars come from the real-time hourly aggregate (24 hourly bars instead of 48 half-hourly ones). Locally with 3,500 monitors: bars 150–230 ms → 18 ms, page 570 KB → 335 KB, dashboard ~170 ms.
Sebi added 1 commit 2026-11-26 20:50:03 +00:00
perf(console): 24 h bars from the hourly aggregate
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 7m5s
ci / test (pull_request) Successful in 13m31s
ci / build (pull_request) Successful in 10m50s
ci / image (pull_request) Successful in 5m30s
4fd11cb45b
The default range bucketed raw results by 30 minutes: for the hundred or
so monitors a dashboard shows, half a million rows on every request. It
shows 24 hourly bars from the real-time hourly aggregate now (bars 150-230
ms to 18 ms locally, the page 570 KB to 335 KB for 3,500 monitors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 383b63bc0e into main 2026-11-26 20:55:56 +00:00
Sebi deleted branch perf/dashboard-large-orgs 2026-11-26 20:55:58 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#164