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

Consider DB Query for Expired Prebuilds at Scale #18217

Labels
@ssncferreira

Description

@ssncferreira

Description

This issue tracks a possible future improvement to the way expired prebuilds are filtered in the system.
Currently, we usein-memory filtering to separate expired from running (non-expired) prebuilds when constructing thePresetSnapshot:

funcfilterExpiredWorkspaces(preset database.GetTemplatePresetsWithPrebuildsRow,runningWorkspaces []database.GetRunningPrebuiltWorkspacesRow) (nonExpired []database.GetRunningPrebuiltWorkspacesRow,expired []database.GetRunningPrebuiltWorkspacesRow) {
if!preset.Ttl.Valid {
returnrunningWorkspaces,expired
}
ttl:=time.Duration(preset.Ttl.Int32)*time.Second
ifttl<=0 {
returnrunningWorkspaces,expired
}
for_,prebuild:=rangerunningWorkspaces {
iftime.Since(prebuild.CreatedAt)>ttl {
expired=append(expired,prebuild)
}else {
nonExpired=append(nonExpired,prebuild)
}
}
returnnonExpired,expired
}

This approach is simple and performs well at the current scale. However, if the number of running prebuilds increases significantly, it may become a performance concern.

Context

Potential Improvement:

  • Introduce a dedicated database query to fetch expired workspaces.
  • Update the currentGetRunningPrebuiltWorkspaces database query to only return non-expired workspaces.
  • This would avoid loading all running prebuilds into memory and manually filtering them.
  • Likely to be more efficient at larger scale.

While in-memory filtering is sufficient for now, introducing a DB query helps future-proof the system and ensures consistent performance in larger on-prem installations.

Action Items

  • Monitor performance as prebuild usage increases.
  • Revisit this issue if:
    • Prebuild count grows significantly.
    • Memory usage or latency becomes a concern in prebuild snapshot construction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp