Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ec9df3

Browse files
authored
fix: reduce impact of GetPrebuildMetrics on database (#19694)
seecoder/internal#959 but the tl; dr is:- we call this DB query on an interval (every 15s) and it would becalled on each coderd replica as well- the generated values update very infrequently (for our most usedinternal template I saw the builds created/claimed update twice in a 1hperiod)- we have no index on the initiator ID, so this query has to scan theentire workspace_builds table on every requestIn reality this should likely just be a Prometheus metric, andPrometheus can handle the counter reset behaviour at query time, but fornow this should at least cut the load of the query to 25% of it'scurrent impact.---------Signed-off-by: Callum Styan <callumstyan@gmail.com>
1 parent2030907 commit0ec9df3

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

‎coderd/database/dump.sql‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Remove index on workspace_builds.initiator_id
2+
DROPINDEX IF EXISTS idx_workspace_builds_initiator_id;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Add index on workspace_builds.initiator_id to optimize prebuild queries
2+
-- This will dramatically improve performance for:
3+
-- - GetPrebuildMetrics (called every 15 seconds)
4+
-- - Any other queries using workspace_prebuild_builds view
5+
-- - Provisioner job queue prioritization
6+
CREATEINDEXidx_workspace_builds_initiator_idON workspace_builds (initiator_id);

‎enterprise/coderd/prebuilds/metricscollector.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ var (
105105
)
106106

107107
const (
108-
metricsUpdateInterval=time.Second*15
108+
metricsUpdateInterval=time.Second*60
109109
metricsUpdateTimeout=time.Second*10
110110
)
111111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp