[PR #248] perf: optimize RRD cache TTL based on time frame #330

Closed
opened 2026-03-07 19:57:36 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/Corsinvest/cv4pve-admin/pull/248

State: closed
Merged: Yes


Summary

  • Replace fixed 30s TTL for all GetRrdDataAsync overloads with a dynamic TTL proportional to the Proxmox RRD time frame
  • Hour → 2 min, Day → 5 min, Week → 30 min, Month → 2h, Year → 12h
  • Reduces unnecessary API calls to Proxmox for longer time frames (Day/Week/Month/Year data changes infrequently)
  • Keeps Hour data reasonably fresh for UI charts and DRS scheduler

Motivation

Previously all RRD requests used a fixed 30s cache TTL regardless of the time frame. A Year graph was re-fetched from Proxmox every 30s even though the underlying data changes once per day. With DRS running every few minutes and using Hour frame, the cache was always cold — every run triggered N sequential API calls (one per node). The new TTL aligns cache lifetime with the natural update frequency of each time frame.

Test plan

  • Open node/VM charts for each time frame (Hour, Day, Week, Month, Year) — data loads correctly
  • Switch time frame on a chart — fresh data is fetched, cache updates
  • Verify DRS run benefits from cache hit on second run within 2 minutes
**Original Pull Request:** https://github.com/Corsinvest/cv4pve-admin/pull/248 **State:** closed **Merged:** Yes --- ## Summary - Replace fixed 30s TTL for all `GetRrdDataAsync` overloads with a dynamic TTL proportional to the Proxmox RRD time frame - `Hour` → 2 min, `Day` → 5 min, `Week` → 30 min, `Month` → 2h, `Year` → 12h - Reduces unnecessary API calls to Proxmox for longer time frames (Day/Week/Month/Year data changes infrequently) - Keeps Hour data reasonably fresh for UI charts and DRS scheduler ## Motivation Previously all RRD requests used a fixed 30s cache TTL regardless of the time frame. A `Year` graph was re-fetched from Proxmox every 30s even though the underlying data changes once per day. With DRS running every few minutes and using `Hour` frame, the cache was always cold — every run triggered N sequential API calls (one per node). The new TTL aligns cache lifetime with the natural update frequency of each time frame. ## Test plan - [ ] Open node/VM charts for each time frame (Hour, Day, Week, Month, Year) — data loads correctly - [ ] Switch time frame on a chart — fresh data is fetched, cache updates - [ ] Verify DRS run benefits from cache hit on second run within 2 minutes
kerem 2026-03-07 19:57:36 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-admin#330
No description provided.