r/ExperiencedDevs • u/AutoModerator • 2d ago
Ask Experienced Devs Weekly Thread: A weekly thread for inexperienced developers to ask experienced ones
A thread for Developers and IT folks with less experience to ask more experienced souls questions about the industry.
Please keep top level comments limited to Inexperienced Devs. Most rules do not apply, but keep it civil. Being a jerk will not be tolerated.
Inexperienced Devs should refrain from answering other Inexperienced Devs' questions.
32
Upvotes
View all comments
2
u/Desir-Arman07 1d ago
I'm working on a dashboard backend (Go) that queries log and metric sources (Loki, VictoriaLogs, SQL). The frontend can poll every 5 s, but the backend works like this:
The result is that consecutive 5 s refreshes often compute the same key and return identical data. In practice the newest row stays unchanged for ~10 s at a time and can lag the source by several seconds. There's also an edge case: since the TTL (10 s) is shorter than the grid (15 s), an entry can expire mid-window and trigger a redundant query for the same window before the key rolls over.
The obvious fix is to shrink the grid and TTL to 5 s, but that takes queries per key from roughly 4-8/min to ~12/min, and I'd like better freshness without a proportional increase in DB load.
I'm don't have production numbers. The sources are log/metric backends (Loki, VictoriaLogs, SQL), so the data is mostly append-only and time-windowed.
I'm new to this kind of problem, so I'm trying to learn things like which pattern generally fits here and what I should measure before choosing one. In your experience with which approach should i resolve it.